Reputation: 2395
When I tried to run the tests VS shows the message: "No tests found to run."
This is my code:
public abstract class MyBaseClassTests
{
protected IRepository Repository;
[TestMethod]
public void Test1 ()
{
var x = this.Repository.Get("id");
Assert.AreEqual(x.Id, "id");
}
}
[TestClass]
public class Implementation1Tests : MyBaseClassTests
{
[TestInitialize]
public void Setup()
{
this.Repository= new MemoryRepository();
}
}
[TestClass]
public class Implementation2Tests : MyBaseClassTests
{
[TestInitialize]
public void Setup()
{
this.Repository= new SqlRepository("connectionString...");
}
}
All the Implementations are in different test projects. (Different Assemblies)
Any suggestion? or is a VS limitation?
Upvotes: 1
Views: 817
Reputation: 1019
Apparently this is a limitation in the Visual Studio test runner for MSTest. The issue is that the test classes are in different assemblies from the base fixture.
My test shows up as long as the base test fixture is located in the same assembly.
edit: no, NUnit doesn't solve it. I was wrong.
The only solution I can offer is to not inherit tests. You can have test helpers, but each test themselves must be typed out for each fixture.
edit2: This stack overflow duplicate suggests that you can link the base class file into each depending test assembly which works around the issue.
Upvotes: 3