GraphWalker is a open source Model-based testing tool for test automation. The features of GraphWalker are path generation both offline and online.

The feature set of GraphWalker

Path generation

  • From a given set of graphs, generators and stop conditions, GraphWalker will generate a path through the graphs.

    Your Model-Based test design consists of 1 or many graphs. Each graph will have it’s own set of generator(s) and stop conditions(s). Only when all stop conditions for all generators in all graphs are fulfilled, the generation of the path is done.

  • The path represents your test, or test case if you will.

    The path is used by your test, to call the corresponding methods or functions in the order that is determined by the path.

  • The path is series of elements, the elements are pairs of edges and vertices.

    It’s like a test script, where an action is always followed by a verification. The path is like:

    Step Label Element type
    1 Do something Edge
    2 Verify something Vertex
    3 Do something Edge
    4 Verify something Vertex
    5 Do something Edge
    6 Verify something Vertex
    : : :
  • An edge represents an action, a transition.

    An action could be an API call, a button clicked, a timeout. Anything that moves your System Under Test into a new state that you want to verify. But remember, there is no verification going on in the edge. That happens only in the vertex.

  • A vertex represents verification(s).

    A verification is where you would have assertions in your code. It’s here where you verify that an API call returns the correct values. That a button click actually did close a dialog. Or that when the timeout should have occurred, the System Under Test triggered the expected event.

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 used by your test automation to drive test.

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.

What GraphWalker does not do

Test execution

GraphWalker does not interact with your system under test. You need some other tool do that. If, for instance, you want to test a web application, you would perhaps use Selenium to do that. Or, if your target is a mobile app, then Appium might be you choice.

Graph editing

Today, the graphs are edited using an external tool called yEd from yWorks.

A web editor supporting editing of directed graphs is underway, and is expected to be included in the 4.0 release of GraphWalker.

Tags: