在Jenkins中使用rerunner-jupiter扩展时,“ junit-jupiter”未能发现测试

时间:2018-06-28 10:30:29

标签: jenkins junit5

如果尝试使用扩展名rerunner-jupiter的测试失败,我会尝试重复测试。在IntelliJ IDEA中它可以正常工作,但在Jenkins上显示此消息失败,

org.junit.platform.launcher.core.DefaultLauncher handleThrowable

WARNING: TestEngine with ID 'junit-jupiter' failed to discover tests
java.lang.NoSuchMethodError: org.junit.platform.engine.support.filter.ClasspathScanningSupport.buildClassFilter(Lorg/junit/platform/engine/EngineDiscoveryRequest;Ljava/util/function/Predicate;)Lorg/junit/platform/commons/util/ClassFilter;
    at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(DiscoverySelectorResolver.java:49)
    at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:61)
    at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:130)
    at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:117)
    at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:82)
    at org.junit.platform.surefire.provider.TestPlanScannerFilter.accept(TestPlanScannerFilter.java:50)
    at org.apache.maven.surefire.util.DefaultScanResult.applyFilter(DefaultScanResult.java:98)
    at org.junit.platform.surefire.provider.JUnitPlatformProvider.scanClasspath(JUnitPlatformProvider.java:121)
    at org.junit.platform.surefire.provider.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:111)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)
Jun 28, 2018 3:22:16 AM org.junit.platform.launcher.core.DefaultLauncher handleThrowable

根本不执行任何测试,整个测试套件一开始都会失败。

1 个答案:

答案 0 :(得分:0)

您可能会收到消息“TestEngine with ID 'junit-jupiter' failed to find tests”,以防您将代码作为名为 java9 模块运行,而您错过了在 module-info.java 中需要一些依赖项。请参阅此答案:https://stackoverflow.com/a/65801052/1874113