Write a Java scenario

A Scenario is a program written in Java that tests different functions of your application.

Your Scenario requires these methods:
  • A play(GhostRunner runner) method, which describes the user interaction sequence to play; that is the sequence of tests it plays.
  • An InvokeFrontcall(String module, String name, String[] args) method, which describes how to handle the call to the front-end client when and if it is required by the application.
  • A getScenarioListener() method. This method is called by the GhostRunner framework to perform runtime monitoring.

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.

Note:

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:

  • Introspecting the application AUI Tree
    • List available actions
    • List available fields
    • Get value of a given field
    • Get field that has the focus
  • Executing a user action
    • Send an action
    • Input a value in a field
    • Scroll through a table
    • Open a tree view node
/**
 * 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.