Reputation: 10153
I implement a test class for unit tests in VS2013
Inside that class I define the following struct and list:
private struct TestCase
{
public string Statement { set; get; }
public string ExpectedStatement { set; get; }
public MyClass[] ContainedEntities;
public MyClass[] NonContainedEntities;
}
private List<TestCase> m_TestCases;
I want to initialize the m_TestCases
with 5 TestCase.
Ho do I do that? Implement Constructor?(once I read that implementing constructor for test class is bad idea).Use ClassInitialize
? but it is static....
Upvotes: 1
Views: 6602
Reputation: 31721
If the data is used in each test and could be mutable (changeable from test to test) then initialize the data in the method with ClassInitialize
as the attribute for it is only loaded once.
If you want it to be loaded before each unit test use TestInitialize
for it will be loaded a new for each test.
See
Upvotes: 1