开发者

Which one runs first: @AfterTest or @TestListener?

开发者 https://www.devze.com 2023-03-15 15:29 出处:网络
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.

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.

The problem is that my 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消