Which one runs first: @AfterTest or @TestListener?
I have a TestNG program that creates files as part of the test but those files need to be deleted after 开发者_如何学运维the test runs. So I will use an @AfterTest
anotation to do this.
TestListener
uses these files to generate error reports after every failed test.
Which one runs first, the @AfterTest
annotation or the attached Listener
?
You could write a simple test application to find the answer you desire. In pseudocode:
someTest() { print "Test was run." }
@AfterTest
afterTest() { print "AfterTest method was run." }
@TestListener
testListener() { print "TestListener method was run." }
Build this and run it; that should help you answer your question.
精彩评论