Java 尝试为我的eclipse应用程序创建Junit

Java 尝试为我的eclipse应用程序创建Junit,java,eclipse,junit,Java,Eclipse,Junit,当我尝试以Junit插件Junit插件测试的形式运行测试时,我正在尝试为我的eclipse应用程序创建Junit: public class QFPROMGridTest { @Test public void test() { System.out.println("Testing HGFYGFYYT"); assertTrue(true); } } 抛出以下错误: BootLoader constants: OS=linux, ARCH=x86_64, WS=g

当我尝试以Junit插件Junit插件测试的形式运行测试时,我正在尝试为我的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)

此错误意味着Eclipse运行时无法在扩展注册表中找到通知它启动的应用程序

要找出问题所在,首先检查控制台输出。应该有一行以
框架参数开头:
,其中包含
-testApplication org.eclipse.ui.ide.workbench
(或另一个testApplication,具体取决于您的设置)

现在打开调试配置。。。对话框,然后首先选中主选项卡。如果您在控制台中找到的应用程序不是您期望的应用程序,则有一个选项“运行应用程序”,您可以使用该选项选择要运行的应用程序

如果应用程序是您想要的,请转到“插件”选项卡,检查是否选择了以下插件:

  • org.eclipse.jdt.junit.runtime
  • org.eclipse.jdt.junit4.runtime
  • org.eclipse.pde.junit.runtime
  • org.eclipse.ui.ide.application
如果没有,请选择这些插件,然后使用AddRequiredPlug-ins按钮添加所有必需的插件

接下来,单击“验证插件”按钮并解决仍然存在的所有冲突

如果验证显示“未检测到任何问题”,请单击“调试”(或“运行”)再次启动测试。它现在应该可以工作了(至少,在最初得到上面的错误并遵循这些步骤之后,它对我来说是这样的…)


注意:如果在启动配置中选择启动产品而不是应用程序,则框架参数可能包含
-product
而不是
-testApplication
。在这种情况下,您需要找出产品启动的应用程序,并确保选择了此应用程序的定义插件及其所有依赖项以供包含

我们可以看到实际的测试吗?我正在尝试打印一个断言为true的公共类QFPROMGridTest{@test public void test(){System.out.println(“Testing hgfyyt”);assertTrue(true);}您到底是如何运行测试的?您执行了哪些步骤?堆栈跟踪与测试不对应您将作为junit插件测试而不仅仅是junit测试运行它。这是故意的吗?