One example: after a password change test executes I would like to a cleanup method to reset the password back to the original password. Annotating the cleanup method with @AfterGroups and making the test method as the only method in a group is one way but it doesn't feel right.
views:
25answers:
1
A:
Hi Craig,
Your suggestion is exactly how I would implement such a functionality, sorry it doesn't feel right to you :-)
How would you prefer to do this?
Cedric Beust
2010-06-25 21:02:21
I would like a cleanup method that would run immediately after another method and would not depend on the first method succeeding. Another ask would be for the cleanup method to run immediately after 2 or more methods ran. Such that methodA runs and then the cleanup method runs and later after methodD runs then the cleanup method runs again. With the @AfterGroups annotation the cleanup method would only be run once after all the methods in the group ran. I would like the cleanup method to run after each method that needs it has run.
Craig Delthony
2010-07-01 16:44:21
This is a bit of a contrived scenario, but maybe you could use a custom annotation for this. Here is how this could work:http://beust.com/weblog/2010/03/23/better-mock-testing-with-testng/
Cedric Beust
2010-07-05 06:25:24