且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JUnit 4.11在@After中获得测试结果

更新时间:2023-11-19 23:22:58

最接近你要求的东西可能是 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.