Launching more than one test in jemmy

267 Views Asked by At

How to launch more than one test class in Jemmy http://java.net/projects/jemmy. I try to use such code but it doesn't work. It launches only one test.

public class Controller {
    public static void main(String[] args) {
        try {
            Class[] testClasses=AllClassesInPackageFinder.getClasses("test");//finds all classes in package with test.
            String[] classFullNames= new String[testClasses.length];
            for (int i=0; i<testClasses.length; i++){
                classFullNames[i]=testClasses[i].getName();
            }
            org.netbeans.jemmy.Test.main(classFullNames);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }
}
2

There are 2 best solutions below

0
On

What you should be using for test execution is a test harness such as JUnit or TestNG.

Jemmy is not a test harness itself.

0
On

You can do it if you create a separate class called ¨Suite¨ where you define the order of your tests and which ones should be executed. Here you have an example:

public class Suite {

public static Test suite() {
    NbModuleSuite.Configuration conf = NbModuleSuite.emptyConfiguration().
            addTest(CreateNewProjectTest.class, "testCreateProject").
            addTest(AddingElementsTest.class, "testOpenExistingProject", "testOpenTestcase",
                    "testAddElement1", "testAddElement2", "testAddElement3", "testPressOk").
            addTest(OtherClassWithSomeTest.class, "test1", "test2", "test3",
                    "test4", "test5", "test6", "test7", "test8");

    return conf.clusters(".*").enableModules(".*").honorAutoloadEager(true).suite();
}

}

As you see you can define the order of the classes (the first added will be the first executed) and inside every class you can define the order of each method too.