Define, Share and Automate your tests / specifications

Simple test class
-
Test class are Groovy class which extend TmarXXX class
-
Tmar4JUnit
-
Tmar4TestNG
-
Tmar4Spock (see chapter dedicated to Spock)
-
-
When a test runs
-
For each iteration
-
It gets values provided by Tmar from the description file
-
Run the Groovy or Java business rules
-
Assigns result values to the Tmar result fields
-
-
At the end Tmar compare those values with each expected value and generates a clear and readable html report.
-
A simple example :
Get and assign data
The simplest way to get iteration data and to assign result values is to us eachIteration with test name for parameter
For each iteration you get a tmar object you can use to retrieve or assign values
eachIteration('multiply') { tmar ->
calculator = new Calculator()
myValue = calculator.multiply(tmar.number1,tmar.number2)
tmar.result = myValue
}
a second syntax let you have the iteration index with the tmar object
eachIteration('multiply') { tmar, iterationNumber ->
...
}
It's also possible to directly get a tmar object before going through the iterations
def myTmarData = getData('multiply')
eachIteration(myTmarData) { tmar ->
...
}
It's sometimes interesting if you want to access tmar table description to initialize context before iterating. ( see Table and Map support )
TmarData object provides three methods for this purpose :
getCurrentIterationNumber()
getIterationHeader()
which returns a map of fields where
key = fieldName
value = Boolean value which is true if the field is a result field (? In the column description)
getIterationValues()
which returns a map of fields where
key = fieldName
value is the value of the field from the Tmar description, Only non-result fields are present in this Map
Examples :
Get current iteration information
accumulation of values
/sequence
[ number 1 | number 2 | result ? | accumulated ? |
| 2 | 2 | 4 | 4 |
| 2 | 3 | 6 | 10 |
| 2 | 4 | 8 | 18 |
tmar.getIterationHeader() ==
[‘number1’:false, ’number2’:false, ‘result’:true, ’accumulated’:true]
tmar.getIterationValues() == [‘number1’:2, ’number2’:2] (first iteration)
tmar.getIterationValues() == [‘number1’:2, ’number2’:3] (second iteration)




