什么是RunUnitners的JUnit 5方式

时间:2018-02-03 07:27:31

标签: junit5

在我们的环境中,我们使用JUnit 4 TestListener将测试结果报告给远程服务器。

JUnit 5的做法是什么?

1 个答案:

答案 0 :(得分:6)

You may use a TestExecutionListener:

http://junit.org/junit5/docs/current/user-guide/#launcher-api-listeners-custom

7.1.4. Plugging in Your Own Test Execution Listeners

In addition to the public Launcher API method for registering test execution listeners programmatically, custom TestExecutionListener implementations discovered at runtime via Java’s java.util.ServiceLoader facility are automatically registered with the DefaultLauncher.

"JUnit 5", read the JUnit Platform, ships some example listeners. You can view their source here:

https://github.com/junit-team/junit5/tree/master/junit-platform-launcher/src/main/java/org/junit/platform/launcher/listeners