Reputation: 203
We have quite a few automated tests, and sometimes one test will spill events to the next test, making the test after fail. To make it clear to everyone that this might be the case, I want to mention previous test/tests in the error message that will be presented.
I know this design is not optimal, but redesigning at this point is not something that will be done.
Is it possible to get the name or other data regarding previously run tests during a test run?
Upvotes: 1
Views: 164
Reputation: 6940
As you said
test will spill events to the next test, making the test after fail
is a poor design of the tests. Each one should follow a Hermetic pattern and be self sufficient. Further more each test should try to revert the System in the initial state, on both pass and fail. This clean up logic can be placed in the TearDown method (e.g. NUnit).
One easy way to
get the name or other data regarding previously run tests during a test run
is to create a global place in which to store all the data from the run e.g. log file. If I had to do it (and assuming the tests are not run in parallel) I would log the name of the test starting and if it passes overwrite it with the next one or just pop it out. If a test fails in it's TearDown link the failed with the previous one using LIFO collection, like a Stack will help you if one test polutes more than one of the others.
Upvotes: 1