How to implement your own testing framework

If you need to implement your own testing framework and not have the GGC manage the execution of the scenarios, you can disable GGC's management with client.disableScenarioWrapper().

To implement your own testing framework:
  • Call the sessionManager.addSession(new MyGenericScenarioImpl(), UABuilder.build()) method to tell GGC to start a new scenario.
  • In the called scenario, call the client.disableScenarioWrapper() method in the setup() method. The client.disableScenarioWrapper() method notifies the GGC to not execute the usual play() method; you want to manage the scenario yourself.
For example:
class MyGenericClientProviderImpl implements ScenarioProvider
{
    private final ConcurrentLinkedDeque<Scenario> scenarios
        = new ConcurrentLinkedDeque<Scenario>(Collections.singleton(new MyGenericScenarioImpl()));

    private final CompletableFuture<Client> futureClient = new CompletableFuture<>();

    // blocking method until Client is ready after first interaction
    public CompletableFuture<Client> getClient() {
        return this.futureClient;
    }

    @Override
    public Scenario nextScenario() {
        return scenarios.poll();
    }

    private class MyGenericScenarioImpl  implements Scenario, ClientListener
    {
        boolean firstInteraction = false;

        @Override
        public void setup(Client client) {
            client.disableScenarioWrapper(); // Notify GGC to not execute play() 
            client.addListener(this);
            client.start(); // Start scenario
        }
        // @Override
        public void clientStarted(Client client) {
            System.out.println("ClientStarted");
        }
        // @Override
        public void clientInteractive(Client client) {
            System.out.println("ClientInteractive");
            if (!firstInteraction) {
               firstInteraction = true; 
               futureClient.complete(client); // unlock getClient() method
             }
        }
  }
}

Once the Genero application has started – you have been notified you got in interactive state – you can use the GGC Client interface to execute the action whenever or wherever you want in your own framework.

For example:
class MyApp {
	public static void main(String[] args) {
           Client c = newClient("http://localhost:6394/ua/r/mytest");
           c.wait(1000);
           c.action("tab");
           c.action("quit");
        }

        private Client newClient(String urlString) {
		Client client = null;
		URL url = new URL(urlString);
		MyGenericScenarioImpl  clientProvider = new MyGenericScenarioImpl  ();
		sessionManager.addSession(clientProvider, UAConfig.Builder(url).build());
          	client = clientProvider.getClient().get();
		return client;
       }
}

This has been a very simple example, to show how you would start managing GGC scenarios yourself. You would need to adapt this example to your needs.