I have following problem. I have some unit tests implemented in a foreign assebly which I reference in my unit test project. The unit tests are implemented as abstract classes and should by inherited (and with it “activated”) in my unit test project.
When I inherit those classes in my project, the test methods are visible to me. But for any reason they are not run by Visual Studio. When I run the tests with Galio Icarus I see a message telling “Test … cannot be found”.
When I copy the abstract test classes into my project, the tests are found and run properly.
Do you know whether there are some restrictions for the methods implementing the unit tests? It looks to me that the test executiion has a logic which not only looks for TestClassAttribute, TestMethodAttribute and so on, but also checks whether the test implementation is done in same assembly.
The implementation looks like this:
abstract class with test implementation in foreign assebly:
[TestClass]
public abstract class GeneralGridTestsBase<T> where T : GridParamsBase, new()
{
[TestMethod]
public virtual void GetCellSetItems_Unique_CellSetKeys()
{
// Test implementation
}
// Other tests implemented here
}
In my test project I inherit the abstract class and expect the tests to be visible and “active”.
[TestClass]
public class RetailInputGeneralTests : GeneralGridTestsBase<RetailInputParams>
{ }
I was able to replicate this and then fix it by overriding the virtual test method and calling the base implementation. It seems uneccessary but I guess it’s just an idiosyncrasy of the MSTest framework: