gpt4 book ai didi

java - 尝试为我的 Eclipse 应用程序创建 Junit

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:21:20 26 4
gpt4 key购买 nike

当我尝试将测试作为 Junit 插件 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)

最佳答案

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

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

现在打开Debug Configurations ... 对话框并首先检查选项卡Main。有一个选项运行应用程序,如果您如上所述在控制台中找到的应用程序不是您期望的应用程序,您可以使用它来选择要运行的应用程序。

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

  • org.eclipse.jdt.junit.runtime
  • org.eclipse.jdt.junit4.runtime
  • org.eclipse.pde.junit.runtime
  • org.eclipse.ui.ide.application

如果没有,请选择那些插件,然后使用添加必需的插件 按钮添加所有必需的插件。

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

如果验证显示“未检测到问题”,请单击“调试”(或“运行”)再次启动您的测试。它现在应该可以工作了(至少,在最初收到上述错误并遵循这些步骤之后它对我有用......)

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

关于java - 尝试为我的 Eclipse 应用程序创建 Junit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28692467/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com