I have test data and test like this below:
private static TestDataClass[] _data =
[
new() {Id = 10, ..},
new() {Id = 20, .. },
...
new() {Id = 170, .. }
]
[Test]
[NonParallelizable]
public void Should_Test([ValueSource(nameof(_data))] TestDataClass data)
{
//call method under test
switch (data.Id)
{
case(10):
// assertions
...
case(170):
// assertions
}
}
Some cases are failing when the tests are done together. Failed tests run fine when I run 1 case at a time from the unit test session. It seemed to me, by de-bugging that there is race condition and so I applied [NonParallelizable]
attribute but it did not fix the issue.