views:

116

answers:

4

I'm trying to write unit tests in MSTest and I've created two TestClasses. When I look at the Test List Editor, the only tests that are shown are the ones that appear in one of the classes.

I can't figure out how to get tests from both of these classes to run. Any ideas?

+1  A: 

Yes, it is definitely possible, and it's odd that all of your tests aren't showing up. Do both of your test classes have the [TestClass()] attribute?

AJ
Both of my classes have the [TestClass] attribute. I'll change it to [TestClass()] and see if that solves it.
Jared
Also, did you add the classes as Add-->New Item-->Class? Or Add-->New Test-->Unit Test? I'm not sure if that would screw it up or not, but it's entirely possible. Just trying to get all the info I can to help you figure this out :)
AJ
I have been using the Add->New Test->Unit Test menu.
Jared
+1  A: 

We have hundreds of test cases in some of our projects. It's not only possible, but essential. Most likely you are missing attributes on the class and/or methods of your test class.

Chris Lively
A: 

It seemed like cleaning the solution, closing Visual Studio, deleting all the TestResults, deleting the .vsmdi file, and deleting the .ncb file and rebuilding the solution have fixed the problem.

Jared
A: 

We have two test projects in a solution and the test list shows all tests from both projects.

I remember that I encountered this issue in the past where some test methods were missing from the test list and i suspect that it has to do whith the bug concerning the .vsdmi files. It can happen if your working with source control and allow multiple check out.

Make sure that: All your test classes have the proper attribute. All your methods have the proper attribute.

If it still happens backup you .vsdmi file put it somewhere else and delete the one(s) that are in your project tree (most likely the root). Then close and reopen your project/solution and hit Test/Window/Test View...

Hope this helps!

Vanof