如何将部件从RCP应用程序链接到SWTBot?

时间:2017-09-21 14:32:20

标签: unit-testing eclipse-rcp swtbot

我开始使用SWTBot来测试我的应用程序Eclipse RCP v4。

这是我的代码,通过id获取部分并激活它。

protected static void openPart(final String id) {
    Display.getDefault().syncExec(new Runnable() {

        public void run() {
            EPartService partService = E4Workbench.getServiceContext().getActiveLeaf().get(EPartService.class);
            MPart part = partService.findPart(id);
            partService.activate(part);
        }
    });
}

这是我的测试。它不起作用......

@Test
public void test1() {
    openPart("testmaker.part.gauche");
    bot.tree().getTreeItem("hju / PQT").expand();
}

@Test
public void test2() {
    openPart("testmaker.part.stepRightSide");
    bot.button("Add Comment").click();
}

我不知道如何将我的private static SWTBot bot;与我的RCP部分联系起来。

我已经尝试使用bot.viewby...(name/id/etc).show();,但它不起作用。

这是我的RCP申请:

enter image description here

有没有人可以帮我使用SWTBot的rcp应用程序?

1 个答案:

答案 0 :(得分:0)

我现在有了解决方案。

使用此插件中的org.eclipse.swtbot.e4.finder插件和类SWTWorkbenchBot,它可以正常工作。