Versions Compared

Key

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

Table of Contents

Overview

GraphWalker is a tool that addresses State Transition Model-Based Testing; in other words, it allows you to perform modeling around states and transitions between those states using directed graphs. 

...

To build the model, we can use a visual tool and (GraphWalker Studio) and export it to a JSON file.

Mapping concepts to Xray

Tests

Besides other entities, in Xray we have Test issues and "requirements" (i.e. issues that can be covered with Tests).

...

The straighforward approach is to consider each model a Test. Remember that a model in itself is a test idea, something that you want to validate; therefore, this seems a good fit.

Requirements

What about "requirements"?

Well, even though GraphWalker allows you to assign one or more requirement identifiers to each vertex, it may not be the best suitable approach linking our model (or parts of it) to requirements. Therefore, and since we consider the model as a Test, we can eventually link each model to a "requirement" later on in Jira.

Results

In sequential scripted automated tests/checkes, we look at the expectaction(s) using assert(s) statement(s), after we perform a set of well-known and static actions. Therefore, we can clearly say that the test scenario exercised by that test either passed or failed.

...

When we "execute the model", it will keep transversing/walking the path and performing checks in the vertices. If those checks are successful until the stop condition(s) is achived, we can say that it was successful; otherwise, the model failed.


Example

In this tutorial, we'll use GraphWalker e-commerce PetClinic example which uses use an example provided by the GraphWalker community (please check GraphWalker model+code) which targets the well-known PetClinic sample site.


Requirements

  • Java 8 
  • PetClinic sample application (requires Java 8 as it is)
    • git clone https://github.com/SpringSource/spring-petclinic.git
      cd spring-petclinic
      git reset --hard 482eeb1c217789b5d772f5c15c3ab7aa89caf279
      mvn tomcat7:run
  • GraphWalker
  • GraphWalker Studio


How can we test it the PetClining using MBT technique?

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.

...

Info
titlePlease note
Remember that you could model it completely differently; modeling represents a perspective.


Models can be built using GraphWalker Studio. We can use it to load previously saved model(s) like the ones in graphwalker-example/java-petclinic/src/main/resources/com/company/PetClinic.json. In this case, the JSON file contains several models; we could also have one JSON file per model.

Image Added

GraphWalker Studio allow us to run the model



Let's pick the NewOwner model as an example.

...

To run the tests we can use Maven. 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
mvn graphwalker:test

This will produce a single JUnit XML report, with one testcase element per each model.

Tips


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).

Image Added

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.

The Execution Details page also shows information about the Test Suite, which will be just GraphWalker.

Image Added

Tips

  • Use use MBT not to replace existing test scripts but in cases where yoou need to provide greater coverage
  • discuss Discuss the model(s) with the team and the ones that can be most useful for your use case
  • after importing the results
  • You can control the seed of the random generator used by GraphWalker, so you can easily reproduce bugs (i.e. by reproducing the generated path)
  • Multiple runs of your tests can be grouped and consolidate in a Test Plan, so you can have an updated overview of their current state
  • After importing the results, you can link the corresponding Test issues with an existing requirement or user story and thus truck coverage directly on the respective issue, or even on a Agile board
    • Image Added
    •   Image Added  Image Added

References