I have a few methods that are used from different class tests. Also, some other common methods are used for preparing the test data.
What is the common practice to handle this in tests?
Should I handle this like any other case by having either base class or some static class (e.g. Utils.CommonMethod()
)? I use static class, since I don't really like the base class in this situation as it will imply that ClassTest1 and ClassTestN are interchangeable.
[TestClass]
public class ClassTest1
{
[TestMethod]
[DynamicData...]
public void Method(TestData data)
{
...
CommonMethod1();
}
public static IEnumerable<object[]> GetTestData()
{
CommonMethod2();
...
}
}
[TestClass]
public class ClassTestN
{
[TestMethod]
[DynamicData...]
public void Method(TestData data)
{
...
CommonMethod1();
}
public static IEnumerable<object[]> GetTestData()
{
CommonMethod2();
...
}
}