Ghost Client and Testing Tools / Testing with Ghost Client |
A Scenario is a program written in Java that tests different functions of your application.
You can decide what tests are to be carried out by providing within the play(GhostRunner runner) function of your scenario the required user interactions.
The complete details of the packages that make up the Ghost Client and the classes and interfaces it uses can be found in the /doc directory of your GGC package. For more information please see the help file by launching the /doc/index.html file in your browser.
Any interaction a user would normally do on an application can be played by a Ghost Client API method:
/** * The Scenario to test the "CustOrders" application from the FGLGWS demo */ public void play(GhostRunner runner) { mRunner = runner; try { // at least, we expect these actions String[] expected = { "zoom_city", "cust_query", "cust_next", "cust_last", "dialogtouched", "cust_append", "cust_delete", "ord_append", "ord_modify", "ord_delete", "close" }; ArrayList<ActionInfo> actions = mRunner.getActions(); for (String act : expected) { boolean present = false; for (ActionInfo action : actions) { if (act.equals(action.getName())) { present = true; break; } } if (!present) { runner.log().error("CustomerOrderScenario: action [", act, "] is missing"); } … } }
In this code sample from the CustomerOrderScenario class sample, the CustOrders application from the FGLGWS demo is being tested for integrity.
The mRunner.getActions() method passes details about the form's menu actions into an array and checks these against an expected list of actions. If an action menu is missing, the runner.log().error method outputs the information to the standard output.