An Action is similar to a Step but can be executed concurrently with other examples.
The After trait can be inherited by classes representing a context where an action must be executing after the main executable action
The After trait can be inherited by classes representing a context where an action must be executing after the main executable action
Example to understand why the type T must : AsResult
For each created example use a given After context
apply an After context to each Example
For each created example use a given after method
This trait can be mixed-in a specification to allow examples to have all of their expectations being evaluated (unless the example body throws an exception of course).
This trait can be mixed-in a specification to allow examples to have all of their expectations being evaluated (unless the example body throws an exception of course).
All the results are collected into a list, provided by the StoredExpectations trait. These results form then the body of the each example (decorated by a special ExampleFactory) so that each example returns a Result which is the summary of all the individual issues.
It must be noted that this trait relies on a mutable list to collect the results as they are created in the example body. Because of this restriction, a Specification using that trait can either run sequentially or isolated.
If the specification is neither sequential or isolated, we force it to be isolated by default.
This trait provides integrated analysis method for a scala project
Apply a Context to a sequence of fragments containing examples.
Apply a Context to a sequence of fragments containing examples.
The context is then applied to each example
The Around trait can be inherited by classes which will execute some code inside the around method provided by the context.
The Around trait can be inherited by classes which will execute some code inside the around method provided by the context.
This can be used for example to execute some code inside a webapp session
Example to understand why the type T must : AsResult
For each created example use a given Around context
apply an Around context to each Example
For each created example use a given around method
The AroundOutside trait can be inherited by classes which will execute some code inside a given context, with a function using that context and actions before and after if necessary.
The AroundOutside trait can be inherited by classes which will execute some code inside a given context, with a function using that context and actions before and after if necessary.
Example to understand why the type T must : AsResult
A Base specification contains the minimum elements for a Specification
A Base specification contains the minimum elements for a Specification
- a Seq of Fragments, available through the SpecificationStructure trait - methods for creating Fragments from the FragmentsBuilder trait - methods to include other specifications
The Before trait can be inherited by classes representing a context where an action must be executing before the main executable action
The Before trait can be inherited by classes representing a context where an action must be executing before the main executable action
Example to understand why the type T must : AsResult
The BeforeAfter trait allows to declare before and after actions to execute before and after an Example
The BeforeAfter trait allows to declare before and after actions to execute before and after an Example
After
Before
The BeforeAfter trait allows to declare before, around and after actions
The BeforeAfter trait allows to declare before, around and after actions
Around
After
Before
For each created example use a given BeforeAfterAround context
apply a BeforeAfterAround context to each Example
For each created example use a given before/after method
For each created example use a given BeforeAfter context
apply a BeforeAfter context to each Example
For each created example use a given before/after method
For each created example use a given Before context
apply a Before context to each Example
For each created example use a given after method
generic trait for Before, After, Around
This trait is only used when we wish to write after actions in unit specifications like this
This trait is only used when we wish to write after actions in unit specifications like this
"an example" ! { 1 must_== 1 }.after(clean)
Decorated creation where the body of the example can be surrounded with a given context if necessary
Decorated creation where the body of the example can be surrounded with a given context if necessary
mutable.BeforeExample
Default implementation for the example factory trait just creating an Example object
A Example is:
A Example is:
- a description: some text, with possibly some markdown annotations for rendering code fragments (used in AutoExamples) - a body: some executable code returning a Result
This trait defines methods for creating Examples.
This trait defines methods for creating Examples.
You can subclass it and implement the newExample(e: Example)
method to provide alternative behavior.
The new factory can be passed to a Specification by overriding the ExamplesFactory.exampleFactory
method
The Executed Fragments represent pieces of a Specification which have already been executed to provide a Result
This executed Fragment is used when no text must be displayed (for the successful execution of an Action for example)
A specification with a name and all of its fragments already executed
The Executing Fragment trait represent a Fragment being executed.
The Executing Fragment trait represent a Fragment being executed.
Some fragments are executed right away, other ones on demand synchronously, and other ones concurrently
a specification with a name and a sequence of fragments being executed
embed an already executed Fragment
A Fixture can be implicitly passed to a set of examples taking a function as an input.
A Fixture can be implicitly passed to a set of examples taking a function as an input.
It can effectively act as an Outside and an Around context
For each created example use a given after method
The FormFormattedString embeds the description of a form as text or as Xml
This trait executes Form Fragments in addition to other fragments
Allow to use forms inside interpolated strings starting with s2 in order to build the specification content
Formatting for Text fragments
Set of fragments which can be used for formatting
Allow a Form to be inserted among Fragments as a Text Fragment Allow a Form to be used as an example body and return a Result automatically
A Fragment is a piece of a specification.
A Fragment is a piece of a specification. It can be a piece of text, an action or an Example
This trait executes Fragments
This trait executes Fragments
It provides a function which executes fragments and returns executed fragments
A Fragments object is a list of fragments with a SpecStart and a SpecEnd
This trait provides function to create specification Fragments:
This trait provides function to create specification Fragments:
This trait post-process fragments.
This trait post-process fragments.
The default implementation looks for tags and sections to mark text and examples as "markdown"
Fragments can be chained with the ^ method
This step can start a sequence of Given / When / Then.
This step can start a sequence of Given / When / Then.
It must define the extract function creating a value of type T from the extracted values
This trait provides building blocks to create steps and examples from regular expression.
This trait provides building blocks to create steps and examples from regular expression.
It is used to implement a Given-When-Then way of describing systems.
Fragments are created by adding a Given
step to a Text
:
"name: ${user}" ^ givenName
This creates a PreStep object containing the current context (representing all the extracted values) and a list of Fragments containing:
Text("name: ${user}")
${}
Then, this PreStep object can be followed by another piece of Text to create a PreStepText object. This object merely
stores the additional Text fragment so that values can be extracted from it when a When
step is added:
// this creates a PreStepText object "name: ${user}" ^ givenName ^ "age: ${38}" // this creates a PreStep object "name: ${user}" ^ givenName ^ "age: ${38}" ^ thenAge ^
Eventually, when a Then
step is added, a sequence of PostStep/PostStepText objects is created. Those objects use
the current context and the results returned by the Then
objects to create Examples.
The last PostStep object contains the list of all fragments created by the Given/When/Then sequence:
This trait can be used to standardize names for groups of examples in an acceptance specification.
This trait can be used to standardize names for groups of examples in an acceptance specification.
class MySpecification extends Specification with Examples { def is = s2""" first example in first group ${g1.e1} second example in first group ${g1.e2}
first example in second group ${g2.e1} second example in second group ${g2.e2} """ }
trait Examples extends Grouped with Matchers { "first group of examples" - new g1 { e1 := ok e2 := ok } "second group of examples" - new g2 { e1 := ok e2 := ok } }
If you don't want to manage groups and examples numbers it is also possible to write the following (note the script.Specification
):
class MySpecification extends script.Specification with Examples { def is = s2""" first example in first group second example in first group
first example in second group second example in second group """ }
trait Examples extends Grouped with Matchers { "first group of examples" - new group { eg := ok eg := ok } "second group of examples" - new group { eg := ok eg := ok } }
This trait can be used to standardize names for groups of examples in an acceptance specification.
This trait can be used to standardize names for groups of examples in an acceptance specification.
class MySpecification extends Specification with Examples { def is = s2""" first example in first group ${g1().e1} second example in first group ${g1().e2}
first example in second group ${g2().e1} second example in second group ${g2().e2} """ }
trait Examples extends Groups with Matchers { "first group of examples" - new g1 { e1 := ok e2 ;= ok } "second group of examples" - new g2 { e1 := ok e2 := ok } }
It is important to notice that the examples must be called with g1().e1
so as to create a new g1
trait instance
with new local variables for the example e1
. If this is not required, the Grouped
trait can be used instead
If you don't want to manage groups and examples numbers it is also possible to write the following (note the script.Specification
):
class MySpecification extends script.Specification with Examples { def is = s2""" first example in first group second example in first group
first example in second group second example in second group """ }
trait Examples extends Groups with Matchers { "first group of examples" - new group { eg := ok eg := ok } "second group of examples" - new group { eg := ok eg := ok } }
The HtmlLink class represents a link in a specification with an identifier (either a spec name, or a string) and link elements.
embed an executing Fragment into a function to execute it on demand
encapsulation of the linking behaviour
This class provides functionalities for manipulating Markdown links
This trait ca be used to deactivate all automatic conversions to examples
This trait deactivates the implicit on Strings which is used to create examples with !
This trait deactivates the implicit on Strings which is used to create examples with !
This is useful to avoid conflict with DataTables
This trait can be used to deactivate the Boolean conversions to fragments and examples
Use this trait to deactivate the Contexts implicits
This trait can be used to deactivate the DataTable conversions to fragments and examples
This trait can be used to deactivate implicits for building fragments
This trait can be used to deactivate the MatchResult conversions to fragments and examples
This trait can be used to deactivate the Result conversions to fragments and examples
This trait can be used to deactivate implicits for ~ and ~/ operators on strings
The Outside trait can be inherited by classes which will execute some code inside the outside method provided by the context.
The Outside trait can be inherited by classes which will execute some code inside the outside method provided by the context.
This can be used for example to execute some code inside a webapp session, using the session object to create expectations
Example to understand why the type T must : AsResult
embed an executed Fragment into a promise
This class is used to evaluate a Context as a sequence of results by side-effects.
This class is used to evaluate a Context as a sequence of results by side-effects.
the AllExpectations trait for its use
Marker trait that is used to create a new scope with variables and implicitly converted to a Success in a mutable Specification
Snippets of code can be extracted from interpolated specification strings.
Snippets of code can be extracted from interpolated specification strings.
When you want to specify that a piece of code must be included in the specification output, you can use the snippet
method to execute a this code and use the text in the output. If you just want to output part of the code you need to
delimit it with some comments // 8<-------
(with as many dashes as you want)
Generally the last value of a snippet will be displayed separately but it is possible to avoid this by using the mute
method on a Snippet.
It is also possible to check that the result value is equal to a specific value by using the check[R : AsResult](f: T => R)
method.
End of a specification.
End of a specification.
This marks the end of the Specification and must have the same name as the corresponding SpecStart.
There is a Boolean flag on a SpecEnd indicating if the whole specification was just executed as a link (for an index page for example) In this case we must not store statistics for this specification (see Storing.scala)
Identification information for a specification
Name declaration for a specification
Start of a specification.
Start of a specification.
This fragment keeps 2 important pieces of information:
additional methods to include other specifications or Fragments
This trait models "what happens" before a fragment is created in terms of side-effects.
This trait models "what happens" before a fragment is created in terms of side-effects.
For now it is mostly used for unit specifications where side-effects can occur inside "blocks" when creating examples. We suppose that acceptance specifications do not have side-effects at creation time.
Allow to use fragments inside interpolated strings starting with s2 in order to build the specification content
The structure of a Specification is simply defined as a sequence of fragments
The Stats class store results for the number of: - successes - expectations - failures - errors - pending - skipped
The Stats class store results for the number of: - successes - expectations - failures - errors - pending - skipped
for each example
An Step creates a fragment that will either return an Error Result if there is an exception or a Success.
An Step creates a fragment that will either return an Error Result if there is an exception or a Success.
It is usually used to do some initialisation or cleanup before or after all the Fragments.
Note that a Step fragment will not be reported in the output.
the ContextSpec specification
This trait can be used when it is not desirable to use the AllExpectations trait, that is, when the specification examples must be executed concurrently and not isolated.
This trait can be used when it is not desirable to use the AllExpectations trait, that is, when the specification examples must be executed concurrently and not isolated.
the UserGuide on how to use this trait
This trait is a context which will use the results provided by the class inheriting that trait.
This trait is a context which will use the results provided by the class inheriting that trait. It evaluates the result of an example, which is supposed to create side-effects and returns the 'storedResults' as the summary of all results
The tags trait allows the creation of Tags fragments in a Specification
Free text, describing the system to specify
This step define checks in a sequence of Given / When / Then.
This step define checks in a sequence of Given / When / Then.
It must define the extract function taking the state of extracted values, T, and return a Result
This step define conditions in a sequence of Given / When / Then.
This step define conditions in a sequence of Given / When / Then.
It must define the extract function taking the previous state of extracted values, P, and creating a new state of type T from the extracted values
Utility methods for fragments
implicit conversions to create Given objects
methods for creating SpecificationStructure instances from fragments
Those standard Fragments are used to format the specification text:
Those standard Fragments are used to format the specification text:
The Stats class store results for the number of: - successes - expectations - failures - errors - pending - skipped
The Stats class store results for the number of: - successes - expectations - failures - errors - pending - skipped
for each example
Those fragments are used to tag other fragments in a specification\
implicit conversions to create Then objects
implicit conversions to create When objects
An Action is similar to a Step but can be executed concurrently with other examples.
It is only reported in case of a failure