Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

From a model, GraphWalker will generate a path through it. A model has a start element, and a generator which rules how the path is generated, and associated stop condition which tells GraphWalker when to stop generating the path.


Generators and stop condtions are essential in GraphWalker (more info here and here), as they influence how the model will be transversed and until when.

Multiple models can interact with one another (i.e. jump from one to other and vice-versa), using shared states (i.e. vertices that have a "shared name").

...

  • action: a way of setting variables in the model or global context; actions are mplemented using JavaScript
  • guard: a way of blocking/guard edges from being walked/executed, usually considering variables stored in the model or global context; guards are implemented using JavaScript.

In sum, we model (i.e. build model) a certain aspect related to our system using directed graphs; the model represents a test idea that describes expected behaviors. Checks are implemented in the vertices (i.e. states) and actions are performed in the edges. GraphWalker will then "walk" the model (i.e. perform a set of "steps"/edges) using a generated path. While doing so, it looks at JavaScript guards to check is edges can be "walked" and performs JavaScript based actions to set internal context variables . It stops "walking" if stop condition(s) are met.

...

Well, one approach could be to model the interactions between different pages. Ultimately they represent certain features that the site provides and that are connected with one another.

In this example, our models arewe'll be using these:

  • PetClinic: main model of the PetClinic store, that relates several models provided by different sections in the site
  • FindOwners: model around the feature of finding owners
  • Veterinarians:  model around the feature of listing veterinarians
  • OwnerInformation: model around the ability of showing information/details of a owner
  • NewOwner: model around the feature of creating a new owner

...

GraphWalker Studio allow us to run the model in offline, i.e. without executing the underlying test automation code, so we can validate it.



Let's pick the NewOwner model as an example.

...

Otherwise, if we fill incorrect data (i.e. using the edge "e_IncorrectData") an error will be shown and the user keeps on the "New Owner" page.




Info
titlePlease note
Usually, to implement the automation code we would create a Maven project from scratch, copy the model file(s), and generate a skeleton of the sources for our model.

# generate a Maven project prepared for GraphWalker
mvn archetype:generate -B -DarchetypeGroupId=org.graphwalker -DarchetypeArtifactId=graphwalker-maven-archetype -DgroupId=com.company -DartifactId=myProject

# store the JSON of the model(s) in src/main/resources/
...

# generate a skeleton of an implementable interface
mvn graphwalker:generate-sources


The Java class that implements the edges and vertices of this model is defined in the class NewOwnerTest. Actions performed in the edges are quite simple. Assertions are also simple as they're only focused on the state/vertex they are at.

...

To run the tests we can use Maven, since there is  a specific plugin for assisting on this. This will produce a single JUnit XML report stored in the target/graphwalker-reports/ directory.

Code Block
languagebash
titleexample of a Bash script to run the tests
rm -f target/graphwalker-reports/*.xml
mvn graphwalker:test


After successfully running the tests and generating the JUnit XML report, it can be imported to Xray (either by the REST API or through the Import Execution Results action within the Test Execution, or even by using a CI tool of your choice).


Code Block
languagebash
titleexample of a Bash script to import the results
REPORT_FILE=$(ls target/graphwalker-reports/TEST-GraphWalker-*.xml | sort | tail -n 1)
curl -H "Content-Type: multipart/form-data" -u admin:admin -F "file=@$REPORT_FILE" http://jiraserver.example/rest/raven/1.0/import/execution/junit?projectKey=CALC


Each model is mapped to JUnit's testcase element which in turn is mapped to a Generic Test in Jira, and the Generic Test Definition field contains the name of the package and the class that implements the model related methods for edges and vertices. The summary of each Test issue is filled out with the name of the class.

...