1
Vote

Class and Namespace contexts not recognized correctly ("Run Tests In Current Context")

description

The "Run Tests In Current Context" command (Ctrl+R, T) should work as follows:
  • with the caret inside a test method, run this test method
  • with the caret inside a class containing test methods, run all tests from this class
  • with the caret inside a namespace, run all tests from all classes from this namespace
     
    Currently only the first case works correctly (inside a test method); in other cases all tests in the solution are run.
     
    The commands "Run Tests in Class" (Ctrl+R, C) and "Run Tests in Namespace" (Ctrl+R, N) also work incorrectly (all tests in the solution are run).

comments

quetzalcoatl wrote Apr 1, 2012 at 12:21 PM

This will may a hard one. I've been recently analysing the exactly same problem in the vs2010 runner for xUnit (xvsr10), and it's apparently a bug or misdesign in the VisualStudio QualityTools itself. I'm preparing a small article about it and explaining how I had circumvented it in xvsr10. It make take a while, though, so if anyone is working on the issue, here's the possible core of the problem: the method Microsoft.VisualStudio.TestTools.TestCaseManagement.GetTestIdsFromCodeElement is used to exactly what it name states, and it perfoms in a three-wise fallback:
  • (A) firstly it searches for tests by hashing the codeelements and checking if generated GUIDs match the hash,
  • then (B) if nothing found, it browses through all known tests and casts them to Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement and checks if they match the codeelement,
  • then (C) if still nothing found, it returns "all tests".

quetzalcoatl wrote Apr 1, 2012 at 12:22 PM

*willmay -> may be

wrote Feb 14, 2013 at 3:16 AM