Altwalker
Introduction
Altwalker is a MBT tool based on GraphWalker. Its input is also a FSM. It supports test generation on Python, C# and .NET programming languages.
Commands
Once installed, it provides a command line utility which, among others, offers the following features;
- check: check the model for issues
- generate: the test cases based on the model
- init: initialise a new project
- offline: generate test in a package in order to execute them later
- online: run the tests
1. Start a new project
Following command will start the new project:
$ altwalker init testsLibrary -l python
It is going to create a directory whose name is testsLibrary directory with two subdirectories:
- model: directory to store models
- tests: directory to store generated tests
This POC is going to create tests using Python language. By default this command creates following directory structure:
The Python file test.py contains following content due to the default model stored on default.json file:
class ModelName:
def edge_A(self):
pass
def vertex_A(self):
pass
def vertex_B(self):
pass
2. Generate test sources
Engineers are going to generate test code based on a particular model. For instance, in the following example, the model is stored into the LibraryApiDemo.json file:
$ altwalker generate -m models/LibraryApiDemo.json testsLibrary2
It will generate the test code with empty implementation:
Alike GraphWalker it requires engineers to implement edges and nodes steps.
3. Online test generation
Online test generation can be obtained by executing following command:
$ altwalker online \ testsLibrary/tests \ -m models/LibraryApiDemo.json \ "random(vertex_coverage(100))"
The model is a JSON file. In order to design the model the AltWalker model editor might be helpful.
Test execution output
Below two test execution output are presented, a failed and a successful one.
Failed execution
Successful execution
4. Offline test generation
AltWalker offers also the ability to generate test using offline mode:
$ altwalker offline \ -m models/LibraryApiDemo.json \ "random(vertex_coverage(100))"
The output is a list of vertexes and edges that the test should go through:
Previous option is easily parseable. Writing the test steps to execute is straightforward:
Conclusion
The article has presented AltWalker tool. It shows the commands offered as well as examples of use. The reader can also check two examples about the same SUT, one using online and another one using offline test generation mode.