"Before" examples
A before example is intended to be used for functionality required by each example where adding it to the specification improves the communication aspect for the reader.
There are two ways of specifying before-all-examples behavior.
Concordion "before"
As e:example
command effectively is the very same concordion example hence it supports the before examples
concordion feature.
<e:example name="before"> The variable
<code>fromConcordionBefore</code> will be reset to
<code e:set="#fromConcordionBefore = now()">{{now "HH:mm:ss.SSS"}}</code> before each example.
</e:example>
will be rendered as:fromConcordionBefore
will be reset
to 15:26:16.797
before each example.
In the following example 1 the fromConcordionBefore
variable is available but fromExamBefore
is not.
fromConcordionBefore
: 15:26:16.811
Echo
fromExamBefore
: null
Exam "before"
Main difference from concordion before is that that content of a e:before-each
command
will be effectively inlined in the beginning of each subsequent example.
For example let's (re)set fromExamBefore
variable before each example.
<e:before-each> The variable
<code>fromExamBefore</code> will be reset to
<code e:set="#fromExamBefore">{{now "HH:mm:ss.SSS"}}</code> before each example.
</e:before-each>
will be rendered as:
Both variables are available, e:before-each
block embedded at the beginning of the each subsequent example.
fromExamBefore
will be reset to 15:26:16.822
before each example.
fromConcordionBefore
: 15:26:16.819
Echo
fromExamBefore
: 15:26:16.822
fromExamBefore
will be reset to 15:26:16.826
before each example.
fromConcordionBefore
: 15:26:16.823
Echo
fromExamBefore
: 15:26:16.826