HelloWorldTest.java
HelloWorldTest
constitutes a simple combinatorial test.
The static method model
defines the complete input parameter model including the desired testing strength and all parameters with their values.
The test
method is written like a normal JUnit5 parameterized test with the difference only being the annotations. @CombinatorialTest
marks the method as a combinatorial test method and provides a reference to the input parameter model.
This means that JUnit will automatically call coffee4j to generate the inputs for the method. T
Once the test execution is started, coffee4j uses the IPOG test selection strategy as defined by @EnableGeneration(algorithms = { Ipog.class })
to generate test inputs.
It will then call the test
method for each generated test input.
ExampleTest.java
The ExampleTest
further introduces constraints in the input parameter model.
In this context, a constraint is a Java method with one or more parameters as its arguments and a return value of type boolean
.
Constraints add semantic information to the input parameter model by labeling combinations of parameter values with either true
or false
.
The unique selling point of coffee4j is the distinction of two different types of constraints:
exclusion-constraints via .exclusionConstraints()
and error-constraints via .errorConstraints()
.
Whenever an exclusion-constraint returns false
for a value combination, this value combination is marked as irrelevant and consequently excluded from all test inputs.
Irrelevant value combinations never appear in any test input.
Whenever an error-constraint returns false
for a value combination, this value combination is marked as invalid.
Invalid value combinations never appear in valid test inputs but in strong invalid test inputs.
To enable the generation of strong invalid test inputs, the IPOG-NEG test selection strategy can be enabled via @EnableGeneration
.
Further on, test selection strategies can be further customized via @ConfigureIpog
and @ConfigureIpogNeg
annotations.
For more information about the distinction of exclusion- and error-constraints, please refer to our publications.
More examples that illustrate additional features such as customization of IPOG-NEG,
automatic detection and repair of over-constrained input parameter models,
automatic generation of error-constraints, and
test oracles based on error-constraints can be found in the example.advanced
package (here).