JUnit 4.11 get test result in @After

后端 未结 5 1256
梦毁少年i
梦毁少年i 2020-12-19 07:09

Is there any way I can get the test result in the teardown (@After) method? I\'d like to do clean up after the tests depending on the result.

Could not

5条回答
  •  [愿得一人]
    2020-12-19 07:32

    Yes, if you use TestNG, it is a standard function, your @After method can look like this:

    @AfterTest
    public void cleanUp( ITestResult result ) {
        boolean success = result.isSuccess();
        ....
    

提交回复
热议问题