I have a class A that I want to test with JUnit. Creating of an object of type A involves a lot of IO, so it takes about 5 seconds.
A is mutable and I want to test the different methods that change A. Now I am in some kind of dilemma:
- If I create a virgin object A for every test method, it just takes too long.
- Creating one huge test method with a lot of asserts seems like a bad idea to isolate the causes of possible errors.
- "Repairing" the object of type A after each test methods seems to dangerous as well because if the repairing is not done correctly, other test methods might fail without proper reason.
- I could also create a deep copy of an instance of A for every test method, but that means that I have to change the class A only to properly test it.
What would you suggest?
Aucun commentaire:
Enregistrer un commentaire