Question

I'm searching for a good tool for writing regression tests for our Java Swing GUI. I found jemmy2 and I'm really satisfied with it.

There is one little drawback though: As the jemmy examples show, I have to write each test class as an org.netbeans.jemmy.Scenario: the test code goes to the public int runIt() method. I prefer to have more conventional unit tests with the usual given-when-then structure and with meaningful assertions. I'd really like to integrate jemmy with a unit testing framework like junit or testng.

So, the question: how can I do that? I know that it's possible because the JellyTools did it - in a NetBeans-specific way.

Alternatively, how can I get meaningful error reports from my jemmy scenarios?

Was it helpful?

Solution

Jemmy could be used with any test harness like JUnit, TestNG, what have you.

You do not need to do anything special - just use Jemmy API directly from test methods. With JUnit and TestNG you also get nice @Before to run the tested app.

Shura

OTHER TIPS

Meanwhile I learned that it's fairly easy:

@Test
public void testSomething() throws Exception {
            //GIVEN
        ClassReference cr = new ClassReference("components.TableFilterDemo");
    cr.startApplication();
    frame = new JFrameOperator("TableFilterDemo");

            //WHEN
            //doing more steps

            //THEN
            //do TestNG assertions
}

The big difference is that this way the test can throw Jemmy-related exceptions. But then, they are meaningful test messages, so it's OK.

As for "meaningful error reports" ....

A decent test harness will create a report saying which tests failed.

If you want to know more of what went wrong, you could get it from the excessive Jemmy log. You will have to provide your own logging to get some meaningful trace on the application level.

Shura

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top