Model Based Testing Tool
Java Max HTML
Switch branches/tags
Nothing to show
Latest commit f75790e Oct 14, 2016 @mukatee mukatee moved junit integration code to examples to avoid cluttering projects…
… with excess junit imports when using osmotester with other frameworks/versions

README.md

OSMO MBT Tool

Tool for generating and executing test cases.

Test models are expressed as Java programs, which the test generator executes based on annotations defined in the model. The test generator can be configured with different algorithms to generate tests in different ways.

The main point with this approach is to provide:

  • Systematic approach to go through the specification and define it more formally in the form of a test model from which the tool can then be used to automatically generate tests.
  • Automated generation of large number of tests for level of coverage not realistic for manual test creation. The set of coverage elements supported:
  • Variable values (all or category-partitions)
  • Covered steps
  • Covered step-pairs
  • Covered state values (defined by annotated methods with return values)
  • Covered state-pairs
  • Requirements (defined in model as illustrated in the example model below).

Example test model:

public class ExampleModel {
  private final Requirements req = new Requirements();
  @Variable
  private int counter = 0;

  @BeforeTest
  public void start() {
    counter = 0;
  }

  @Guard("decrease")
  public boolean toDecreaseOrNot() {
    return counter > 1;
  }

  @TestStep("decrease")
  public void decreaseState() {
    req.covered(REQ_DECREASE);
    counter--;
    System.out.println("- " + counter);
  }

  @Guard("increase")
  public boolean shallWeIncrease() {
    return counter > 0;
  }

  @TestStep("increase")
  public void increaseState() {
    req.covered(REQ_INCREASE);
    counter++;
    out.println("+ " + counter);
  }
}

The tests can then be executed by configuring the generator such as:

  public static void main(String[] args) {
    OSMOTester tester = new OSMOTester();
    tester.addModelObject(new ExampleModel());
    tester.setAlgorithm(new RandomAlgorithm());
    tester.setTestEndCondition(new Length(100));
    tester.setSuiteEndCondition(new Length(100));
    tester.generate(333);
  }

This generates 100 tests, each with 100 steps. Each step is chosen randomly based on the set of enabled steps.

Installing

Currently the suggested method is to use the Maven repository. Either as a dependency or download the jar file from the repository. Dependency:

<dependency>
	<groupId>net.kanstren.osmo</groupId>
	<artifactId>osmotester</artifactId>
	<version>3.5.0</version>
</dependency>

or direct link

The required core dependencies should be only Log4J2 (api and core jars). Some of the reports use Velocity, and some of the JUnit integration uses JUnit. But those should not be strict requirements if you do not use those features.

Documentation

Some documentation exists here:

License

LGPL License