JUnit 4.11在@After中获得测试结果 [英] JUnit 4.11 get test result in @After
问题描述
有没有办法可以在拆解( @After
)方法中获得测试结果?我希望在测试后根据结果进行清理。
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.
找不到关于 @After $ c $的更多细节c>在junit docs中。
Could not find much details about @After
in the junit docs.
推荐答案
最接近你要求的东西可能是 TestWatcher 规则。这不会让您访问返回的结果或任何内容,但您可以使用它(或创建自己的 TestRule 并结合Description对象,您可以对方法进行不同的注释,以指示需要进行哪种清理。
The closest thing to what you're asking for would probably be the TestWatcher rule. That won't give you access to a returned result or anything, but you can use it (or create your own TestRule and combined with the Description object, you could annotate your methods differently to indicate what sort of clean-up is necessary.
这篇关于JUnit 4.11在@After中获得测试结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!