The GraphWalker supports two ways of test path generation - offline and online.

Offline

Model

The path generation is done once. It’s not directly connected to any test automation code. The path needs to be stored in some intermediate format. Typically, the path is generated from command line, and the output stored on file. The content of the file is then would be used by your test automation to drive tests or for a manual execution.

Example

Given the following graph example_1.graphml, a path can be generated by running a command from a terminal. Below is an example of a generated path from that graph using a random path generator with an edge coverage stop condition. The test will start at the element app_closed

java -jar graphwalker-cli-3.4.2.jar offline --start-element app_closed --model example_1.graphml "random(edge_coverage(100))"
{"currentElementName":"app_closed"}
{"currentElementName":"start_app"}
{"currentElementName":"app_running"}
{"currentElementName":"close_app"}
{"currentElementName":"app_closed"}
{"currentElementName":"start_app"}
{"currentElementName":"app_running"}
{"currentElementName":"open_preferences"}
{"currentElementName":"display_preference"}
{"currentElementName":"close_preferences"}
{"currentElementName":"app_running"}

To make the output only print out the element names, we can use the jq command, and run following instead:

java -jar graphwalker-cli-3.4.2.jar offline --start-element app_closed --model example_1.graphml "random(edge_coverage(100))" | jq -r '.currentElementName'
app_closed
start_app
app_running
close_app
app_closed
start_app
app_running
open_preferences
display_preference
close_preferences
app_running

Online

Model

The path generation is done during the execution of the test, run-time. This means that GraphWalker needs to be embedded in your test automation code. This adds a bit of complexity, but the advantages are:

  • No need to handle the intermediate path sequences in files.

    If your test automation is written in Java, it’s pretty straight forward. You annotate a Java class with @GraphWalker.
    The class represents you graph, and the methods in that class represents the elements in that graph. Using maven, running the test with GraphWalker is done by:

    mvn graphwalker:test
    

    GraphWalker will call the methods in the class during path generation.

  • Your test automation code has direct access to the graphs execution context.

    When GraphWalker generates paths, it keeps all data regarding the generation in an execution context. Your test can query for data in your model, and it can even change data in your model.

    An example is the Amazon example. The code at ShoppingCartTest.java line 65 shows how the current value for the property num_of_books is fetched using getAttribute from the model.

And the next step after test path generation should be tests execution

Tags: