JUnit5 Platform Launcher API - Cannot create Launcher without at least one TestEngine

家住魔仙堡 提交于 2019-12-08 05:40:42

问题


I am attempting to upgrade the testing abilities of our automated testing suite to accept JUnit5 tests and when following The JUnit Platform Launcher API instructions I get the error "Cannot create Launcher without at least one TestEngine; consider adding an engine implementation JAR to the classpath". The cause is that the following is unable to find any instances of TestEngine:

Iterable<TestEngine> testEngines = ServiceLoader.load(TestEngine.class,ClassLoaderUtils.getDefaultClassLoader());

Do you have any suggestions on how to ensure that the ServiceLoader is able to find an instance of TestEngine?

I have included org.junit.jupiter.engine, which contains JupiterTestEngine which implements TestEngine, as a required plugin. I have tried adding a direct path to the jupiter.engine jar in the project's .classpath. I have tried creating an instance of JupiterTestEngine witihn the same file and it is created successfully, but still no TestEngines found by the service loader.

EDIT (In response to Sormuras's comment):

This is for Eclipse and you can see the code base here: http://git.eclipse.org/c/platform/eclipse.platform.releng.git/tree/bundles/org.eclipse.test

I added the following to the mainifest:

org.junit.platform.launcher,
org.junit.jupiter.api;bundle-version="5.0.0",
org.junit.platform.engine;bundle-version="1.0.0",
org.junit.platform.commons;bundle-version="1.0.0",
org.junit.jupiter.engine;bundle-version="5.0.0",
org.junit.vintage.engine;bundle-version="4.12.0"

Added this to the .classplath:

<classpathentry exported="true" kind="lib" path="/home/lbullen/Documents/eclipse/plugins/org.junit.jupiter.engine_5.0.0.v20170910-2246.jar"/>

Added the org.junit.jupiter.engine jar to the lib folder then added it to be included in the binary build. (I'm streatching for a solution)

And I'm trying to get the Tutorial code to work in an edited version of http://git.eclipse.org/c/platform/eclipse.platform.releng.git/tree/bundles/org.eclipse.test/src/org/eclipse/test/EclipseTestRunner.java with all the old junit code removed.

来源:https://stackoverflow.com/questions/48672051/junit5-platform-launcher-api-cannot-create-launcher-without-at-least-one-teste

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!