我使用SWTBot 2.8.0进行了一些非常简单的UI测试(在编写最新版本时)。这些都保存在Eclipse插件片段中,并且不使用JUnit 4的任何细节,比如@RunWith(SWTBotJunit4ClassRunner.class)。
public class MyTest {
private final SWTBot bot = new SWTBot();
@Test
public void test() {
// …
}
}现在,如果我从org.junit.Test切换到JUnit 5的org.junit.jupiter.api.Test,然后尝试通过run > SWTBot测试运行测试,则会得到以下错误:
Exception in thread "WorkbenchTestable" java.lang.IllegalArgumentException: Error: test loader org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader not found:
org.junit.platform.commons.util.PreconditionViolationException: Cannot create Launcher without at least one TestEngine; consider adding an engine implementation JAR to the classpath
at org.junit.platform.commons.util.Preconditions.condition(Preconditions.java:295)
at org.junit.platform.launcher.core.DefaultLauncher.<init>(DefaultLauncher.java:58)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:91)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:67)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.<init>(JUnit5TestLoader.java:34)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:370)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:365)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:309)
at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.init(RemotePluginTestRunner.java:85)
at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main(RemotePluginTestRunner.java:63)
at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(UITestApplication.java:120)
at org.eclipse.e4.ui.internal.workbench.swt.E4Testable.lambda$0(E4Testable.java:76)
at java.lang.Thread.run(Thread.java:748)如果我中止了执行,接下来是在Runner: JUnit 5消息中找到一个No测试。
我的MANIFEST.MF包含以下几行:
Require-Bundle: org.eclipse.swtbot.swt.finder;bundle-version="[2.7.0,3.0.0)",
org.junit;bundle-version="[4.12.0,5.0.0)",
org.junit.jupiter.api;bundle-version="[5.4.0,6.0.0)",
org.junit.jupiter.engine;bundle-version="[5.4.0,6.0.0)"为了消除上述异常,我还需要向Require-Bundle头添加什么呢?
备注:相反,运行As > JUnit插件测试正确地初始化测试运行程序( JUnit视图显示带有Runner: JUnit 5的测试Test.test ),但随后冻结测试,当然,测试运行在UI威胁上,这是一个不去做SWTBot测试。
发布于 2020-05-24 09:19:35
SWTBot将只支持从Eclipse2020-06发布的Eclipse3.0开始的JUnit 5,根据邮寄名单公告的说法。
https://stackoverflow.com/questions/58543338
复制相似问题