9

When I attempt to "Run Tests in current context" it runs every test in the entire solution.

This used to work fine but now seems to have either a bug or a configuration problem.

Thanks.

6 Answers 6

2

Are you using VS Test tools? If so, I have seen this same problem, especially with new tests or a new test assembly. One thing that helps me is going to the "Test View" window, refreshing the tests list and then highlighting a block of code within the test I want to run. Then, hit the Run or Debug Tests in Current Context button.

0
2

When I ran into this the problem was that the test project that I added to the solution wasn't actually set to build under the Solution Properties > Configuration Properties. Once you make sure it's actually building it'll have the proper context to run that test.

0

Not exactly a direct solution to your problem, but I have found that the TestDriven.net tool does a better job of executing tests than VS itself. It also supports running just any code that does not require parameters which can be very useful at times, as well as supporting a host of other test frameworks.

0

I strongly recommend TestDriven.net. It makes running and debugging unit tests very simple. It comes with NCover which gives you test coverage.

1
  • 1
    Very helpful answer, but I think it would be better as a comment rather than an answer, since (as far as I can tell) it proposes a different direction rather than directly solving the asker's question. Oct 11, 2013 at 21:55
0

Another reason can be that the project containing tests is not a test project from VS' point view. Make sure you've got something like the following in the project file <PropertyGroup> section.

<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

0

Yet another reason why this happens is that I was trying to run a single test from an abstract class. This loads all derived classes and launch all tests from the base class for each of them.

In that case, there's no real other choice than to run the test from the Test List Editor window:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.