Model-based testing using ModelJUnit Add comment to Wiki View in Wiki Edit Wiki page Printable Version

ModelJUnit is a Java library that extends JUnit to support model-based testing.

In this example, we will consider how to model and test a simple vending machine. The system under test is illustrated by the following state diagram:

The VendingMachineModel class models this system. Our script makes use of the RandomTester class to generate some tests for this model. The total code looks like this:

When we run this script, we will see the randomly generated test transitions. The output will be:

We can optionally obtain additional metrics about the test:

This generates the following:

We can also add a graph listener with the following code:

When run, a graphviz dot file is produced (corresponding to the image above) and the output is:

See also: State Pattern



Results of your search request can come from various sources: the Groovy website itself, the JIRA issues, the API documentation, as well as a few other interesting Groovy-related blogs.

  By  -  pages  -  views  - last modified