Patrick Szalapski
Patrick Szalapski

Reputation: 9439

Visual Studio test project with MSTest tests reports "the project does not contain any tests"--though it does

I have a Visual Studio 2010 solution with several projects, including .NET4 test projects. One such project, when I try to run it without debugging (Ctrl+F5), reports:

"Cannot start test project MyTestProject because the project does not contain any tests."

But, the project has several tests. Each test class is marked with the [TestClass] attribute, and each test method within is marked with the [TestMethod] attribute. Just to demonstrate my own sanity, I added this file and it still wouldn't recognize that there are tests.

using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Foo {
    [TestClass]
    public class UnitTest1 {
        [TestMethod]
        public void TestMethod1() {
        }
    }
}

The project is properly set as a test C# project. The tests in question also fail to show up in the Test List Editor's "Tests not in a list" section. (I translated most of the tests from VB.)

Why isn't Visual Studio recognizing the tests? How could I troubleshoot it?

Upvotes: 0

Views: 1937

Answers (1)

Patrick Szalapski
Patrick Szalapski

Reputation: 9439

Turns out that these tests were translated to C# from VB; when I translated them, I forgot to add explicit namespaces on them. Thus there were two test classes in the global namespace with the same name, which caused one to effectively replace the other. I just wish the warning given was a little less cryptic!

Upvotes: 1

Related Questions