javaeclipseswteclipse-rcpswtbot

swtbot failing when resetting workbench


I have a test like this

public class TesteSairApp extends GermantechTest {

    @Test
    public void testApp() throws Exception {
        SWTBotMenu file = bot.menu("Arquivo");
        bot.sleep(1000);

        SWTBotMenu clickSair = file.menu("Sair");
        bot.sleep(1000);

        SWTBotMenu menuClicado = clickSair.click();
        System.out.println(menuClicado);
        bot.sleep(1000);

        pass();
    }

which just quit the app.
After the app quit, I got this exception:
java.lang.NoClassDefFoundError: org/hamcrest/Matchers at org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot.editors(SWTWorkbenchBot.java:222) at ...

If I remove the bot.resetWorkbench(); from @After in GermantehcTest, the test passes...
What is wrong here?


Solution

  • It looks to me like a dependency issue. Did you include org.hamcrest in the manifest of your tests? If so take a look at the org.hamcrest bundle. As a guess the class 'org.hamcrest.Matchers' is missing there. Depending on the distribution of hamcrest you have chosen, this class might be missing (on purpose). Afaik it is missing in the hamcrest-core-xy.jar. You could try to add the Hamcrest additional library of matchers to your target and your manifest. If this works I would suggest to bake your own bundle of hamcrest-all, using this as a base (I did not find a hamcrest-all as a bundle as a download).