Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为eclipse RCP应用程序运行Junit测试用例的问题_Java_Eclipse_Junit_Swtbot - Fatal编程技术网

Java 为eclipse RCP应用程序运行Junit测试用例的问题

Java 为eclipse RCP应用程序运行Junit测试用例的问题,java,eclipse,junit,swtbot,Java,Eclipse,Junit,Swtbot,在测试Eclipse4RCP应用程序的退出处理程序时,我面临以下异常 !ENTRY org.eclipse.e4.ui.workbench 2 0 2014-06-10 14:09:22.607 !MESSAGE Could not run processor !STACK 0 org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException at org.eclipse.e4.core.internal.

在测试Eclipse4RCP应用程序的退出处理程序时,我面临以下异常

!ENTRY org.eclipse.e4.ui.workbench 2 0 2014-06-10 14:09:22.607
!MESSAGE Could not run processor
!STACK 0
org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:243)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:220)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:107)
    at org.eclipse.e4.ui.internal.workbench.ModelAssembler.runProcessor(ModelAssembler.java:231)
    at org.eclipse.e4.ui.internal.workbench.ModelAssembler.processModel(ModelAssembler.java:88)
    at org.eclipse.e4.ui.internal.workbench.ResourceHandler.loadMostRecentModel(ResourceHandler.java:220)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.loadApplicationModel(E4Application.java:395)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:238)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:144)
    at org.eclipse.swtbot.eclipse.core.UITestApplication.start(UITestApplication.java:54)
    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(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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)
Caused by: java.lang.NullPointerException
    at org.eclipse.e4.tools.emf.liveeditor.ModelProcessor.process(ModelProcessor.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
    ... 23 more
我的测试用例如下所示

    @RunWith(SWTBotJunit4ClassRunner.class)
public class ExitHandlerTest {

    private static SWTBot bot;

    @BeforeClass
    public static void beforeClass() throws Exception {
        bot = new SWTBot();
    }

    @Test
    public void testExitHandler() {
        SWTBotMenu fileMenu = bot.menu("File");
        Assert.assertNotNull(fileMenu);
        SWTBotMenu exitMenu = fileMenu.menu("Exit");
        Assert.assertNotNull(exitMenu);
        exitMenu.click();
    }

    @AfterClass
    public static void sleep() {
    }

}
我的exist处理程序的代码是

public class ExitHandler {
    @Execute
    public void execute(IWorkbench workbench, EPartService partService, ISaveHandler saveHandler) {
        workbench.close();
    }

}

虽然测试运行正常,但我不确定为什么会出现此异常。

看起来您的测试中包含了e4 live模型编辑器,并且遇到了Eclipse错误


我认为这实际上不会影响您的测试,所以您可以忽略它。

堆栈跟踪中是否存在由引起的部分?该部分可能会有所帮助。非常感谢您的回复,但我不确定如何修复它。我要说的是从日志中向我们显示错误的更多详细信息,因为我认为这将有助于诊断问题。很抱歉,我误解了,但我已更新了我的问题。