为所有测试类设置自定义testexecutionListener,因此我可以记录每个例外/断言的堆栈跟踪

StackOverflow https://stackoverflow.com/questions/4748008

嘿,我正在使用SpringJunit4Classrunner。默认情况下,testContextManager.aftertestmethod()记录每个异常或断言非常简短(只是消息),例如:

testMethod = testDataDriven@DataDrivenAbstractTest, testException = [null]]

我想编写一个自定义testexecutionListener 任何测试 在我的项目中。我不想记住用@TestExecutionListeners注释我的每个测试课程。

我可以以某种方式在全球上做吗?我在正确的道路上吗?

谢谢。

有帮助吗?

解决方案

不,您不能在全球范围内做到这一点,但是您可以编写使用该基类 TestExecutionListener 并让所有其他测试类扩展它。

或者您可以扩展 SpringJUnit4ClassRunner 做您的工作并进行测试 @Runwith(YourCustomSpringJUnit4ClassRunner.class)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top