We are writing application service tests across our Data Service Class.
Currently writing tests liking add Product, remove Product, check for inventory after sale, etc. They are all using the same data storage in a list, BeforeEach Method.
When they are all utilizing the same data set, I'm afraid changing one piece of data, will affect all the other unit test. Is that the proper unit test method, or should unit tests have their own data set or factory method?
product.Add(
new Product
{
ProductId= "1",
Quantity= 5,
Code= "Table",
},
new Product
{
ProductId= "2",
Quantity= 7,
Code= "Food",
}
}
I understand, Unit Tests should not modify each others data. The question is even if they have same data setup clones in individual memory sets, changing the common data setup can affect other test results, which still leads to tightly coupled. Is this good practice?