One example: after a password change test executes I would like to a cleanup method t开发者_Go百科o 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.
This question might provide some help: TestNg, annotation "beforeTestMethod" and override. It's a very similar question, but with customizing the @BeforeMethod instead of the cleanup (@AfterMethod). Essentially, you could create a base test class, and have a child test class that contains all the methods requiring password reset, and which supplies it's own @AfterMethod. This may or may not be a logical choice in your situation, depending on your tests, of course.
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?
精彩评论