当我尝试以Junit Plugin Junit-Plugin测试运行测试时,我试图为我的eclipse应用程序创建一个Junit:
public class QFPROMGridTest {
@Test public void test() {
System.out.println("Testing HGFYGFYYT");
assertTrue(true);
}
}
抛出以下错误,
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments: -version 3 -port 51827 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames com.qualcomm.qti.fusemaster.junitTest.QFPROMGridTest -application org.eclipse.pde.junit.runtime.nonuithreadtestapplication -product org.eclipse.platform.ide -testpluginname com.qualcomm.qti.fusemaster.junitTest
Command-line arguments: -os linux -ws gtk -arch x86_64 -consoleLog -version 3 -port 51827 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames com.qualcomm.qti.fusemaster.junitTest.QFPROMGridTest -application org.eclipse.pde.junit.runtime.nonuithreadtestapplication -product org.eclipse.platform.ide -data /prj/iceng/qsip1/workspaces/c_hgarik/fusemaster_workspace_Jan19/../junit-workspace -dev file:/prj/iceng/qsip1/workspaces/c_hgarik/fusemaster_workspace_Jan19/.metadata/.plugins/org.eclipse.pde.core/pde-junit/dev.properties -os linux -ws gtk -arch x86_64 -consoleLog -testpluginname com.qualcomm.qti.fusemaster.junitTest
!ENTRY org.eclipse.osgi 4 0 2015-02-24 01:38:45.002
!MESSAGE Application error
!STACK 1
junit.framework.AssertionFailedError
at junit.framework.Assert.fail(Assert.java:55)
at junit.framework.Assert.assertTrue(Assert.java:22)
at junit.framework.Assert.assertNotNull(Assert.java:256)
at junit.framework.Assert.assertNotNull(Assert.java:248)
at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.getApplication(NonUIThreadTestApplication.java:103)
at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.start(NonUIThreadTestApplication.java:36)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
答案 0 :(得分:2)
此错误意味着Eclipse Runtime找不到它被告知在扩展注册表中启动的应用程序。
要找出错误,请先检查控制台输出。应该有一行以Framework arguments:
开头,其中包含-testApplication org.eclipse.ui.ide.workbench
(或其他testApplication,具体取决于您的设置)。
现在打开调试配置... 对话框,首先检查选项卡 Main 。如果您在控制台中找到的应用程序不是您期望的应用程序,则可以使用运行应用程序选项来选择要运行的应用程序。
如果应用程序是您想要的应用程序,请转到插件选项卡,检查是否选择了以下插件:
如果没有,请选择这些插件,然后使用添加必需的插件按钮添加所有必需的插件。
接下来,单击验证插件按钮并解决仍然存在的所有冲突。
如果验证显示"未检测到任何问题",请单击"调试" (或"运行")再次启动测试。它现在应该工作(至少,它在最初得到上述错误并遵循这些步骤后为我做了...)
注意:如果您已选择在启动配置中启动产品而不是应用程序,则Framework参数可能包含-product
而不是-testApplication
。在这种情况下,您需要找出产品启动的应用程序,并确保选择此应用程序的定义插件及其所有依赖项。