Reputation: 726
I have EntityServiceBaseTestClass that is generic and it has generic tests. However, as soon as I inherit the class in my particular test domain, the tests are not run. But, if I put my inherited test class in the same assembly as the base test class it works. Ho can trick Visual Studio to run the base class test even if it is in different assembly. For example:
**namespace bla bla...Domain.Tests**
[TestClass]
public class EntityServiceBaseTestClass<TDomainEntity, TKey> where TDomainEntity :
DomainEntityBase<TDomainEntity, TKey> where TKey :
IEquatable<TKey>
{
[TestMethod]
public void CanSaveAddressMustUpdate()
{
//do generic tests
}
}
**namespace bla bla...Domain.Customers.Tests**
{
[TestClass]
public class CustomerTests : EntityServiceBaseTestClass<Address, Guid>
{
some specific domain tests
}
}
The CanSaveAddressMustUpdate()
is not getting called if the file is not in the same assembly.
The explanation for that restriction I found here msdn:
"A test class can inherit methods from another test class that is in the same assembly. This means that you can create test methods in a base test class and then use those methods in derived test classes"
Upvotes: 2
Views: 963
Reputation: 871
Since there is the restriction is documented by Microsoft I guess you will not have any chance to workaround.
What you can do is to change your test framework. With Nunit everything is working like a charm (tested with the ReSharper Test Runner).
Upvotes: 1