I have a log analyzer that I'm working on, and this log parser has an ILogStore interface that defines the basic methods for any mechanism for storing log entries (in memory, in the database, etc.). The idea is that developers and users can add or remove log storage mechanisms through the MEF plugin interface.
However, to confirm that the ILogStore implementation can correctly store, filter, and retrieve log entries, I created a base class for unit / integration / API testing:
public class LogStoreBaseTests { protected ILogStore _store; [TestMethod] public void Can_Store_And_Retrieve_Records() { } [TestMethod] public void Can_Filter_Records_By_Inclusive_Text() { } [TestMethod] public void Can_Filter_Records_By_Exclusive_Text() { }
I am testing my implemented tasks by doing something like:
[TestClass] public class InMemoryLogStoreTests : LogStoreBaseTests { [TestInitialize] public void Setup() { _store = new InMemoryLogStore(); } }
This works well, except that MsTest notices that the methods in the base class have [TestMethod] , but errors because the class does not have [TestClass] , which does not happen because it is not a valid test on it.
How can I tell MsTest to ignore methods when they are not executed from a subclass?
source share