First of all I have read some great answers in the following link: Are your UI automated tests dependent or ordered?. But would like a clearer understanding in terms of dependencies within test data.
I'll be straight forward here and give an example, we have two tests A and B:
- A tests for if an object can have a unique attribute
- B test for if an object can have another unique attribute
- The object cannot have two attributes at the same time
Right now I am trying to decide on whether I should use two separate or one single object to test these cases.
If I were to use one, then test A (or test B) would have to make sure that it removes the attribute from the object after the test is finished, so that other tests can add other attributes to the same object. This seems like dangerous dependency to me because if test A fails to remove the attribute for some reason, it would have an impact on all following tests.
This can be resolved by using two separate objects, but then the problem is that this will likely require one object per test, which introduces a huge amount of objects that I might not be able to offer for my current test suits.
I would like to know what is the normally preferred approach in the software testing field, and the best practice I could implement given my situation. Thanks!