CUnit
CUnit copied to clipboard
Isolate every test cases that are in a single test method
The test cases in a single test method may capture common variables in the method header. So a test case may affect each other.
public void Foo()
{
var a = 1;
"Test case 1".Test(() =>
{
a++;
Assert.AreEqual(a, 2);
});
"Test case 2".Test(() =>
{
a++;
Assert.AreEqual(a, 2);
});
}
I recommend isolating every test cases that are in a single test method.