The execution of Concordion commands can be observed using listeners
. Listeners have access to the HTML element with which the command is associated,
and can modify the output HTML.
An extension is installed that listens to assertEquals, assertTrue, assertFalse and execute commands. When the following instrumentation:
<p concordion:execute="#result=sqrt(#num)">The square root of <span concordion:set="#num">4.0</span> is <span concordion:assertEquals="#result">2.0</span></p> <p concordion:execute="#result=sqrt(#num)">The square root of <span concordion:set="#num">16.0</span> is <span concordion:assertEquals="#result">3.0</span></p> <p><span concordion:set="#num">3</span> is <span concordion:assertTrue="isPositive(#num)">is positive</span> </p> <p><span concordion:set="#num">-4</span> is <span concordion:assertTrue="isPositive(#num)">is positive</span> </p> <p><span concordion:set="#num">-5</span> is <span concordion:assertFalse="isPositive(#num)">is not positive</span> </p> <p><span concordion:set="#num">6</span> is <span concordion:assertFalse="isPositive(#num)">is not positive</span> </p>
is run with a fixture that performs the arithmetical operations, the logged events are:
Event |
---|
Set #num = '4.0' |
Execute 'The square root of 4.0 is 2.0' |
Success '2.0' |
Set #num = '16.0' |
Execute 'The square root of 16.0 is 3.0' |
Failure expected:'3.0' actual:'4.0' |
Set #num = '3' |
Success 'is positive' |
Set #num = '-4' |
Failure expected:'is positive' actual:'== false' |
Set #num = '-5' |
Success 'is not positive' |
Set #num = '6' |
Failure expected:'is not positive' actual:'== true' |
Run listeners
are notified of the outcome of run commands (success, failure or ignored)Throwable caught listeners
are notified of any throwables
that occur while processing a command, including custom commands.Concordion build listeners
provide access to the target
to allow resources to be writtenDocument parsing listeners
provide access to the document
prior to parsingSpecification processing listeners
provide access to the specification
before and after processingSee the processing listeners specification for examples.