-
Notifications
You must be signed in to change notification settings - Fork 7
Supported Language
StorEvil supports a subset of the Gherkin language.
Anything before the first line that starts with "scenario" is not executed.
This can be multiple lines long.
Scenario: This is a scenario title
Given some precondition.
When some awesome action is invoked
An exact match is when a method matches an entire line of specification code.
These would be exact matches for lines in the above specification:
public void Given_some_precondition() {}
public void When_some_qualifier_action_is_invoked(string qualifier) {}
A partial match happens when there is a method that matches part of a line:
public ActionContext When_some_qualifier_action(string qualifier) { }
Note that a partial match must return a value (in this case, ActionContext
).
StorEvil will attempt to match the rest of the line using the returned value, so, we might define ActionContext as follows:
[StorEvil.Context] public class ActionContext {public void Is_invoked(){}}
StorEvil favors an exact match over any partial matches, and favors longer partial matches (more words) over shorter matches (fewer words).
“Given”, “When” and “Then” are not hard-wired into the language… you may use any words you like for these concepts.
If the first word of a line is “And”, and there is no grammar match using “And”, StorEvil will attempt to use the most recent significant first word .
For example, given in the following,
Scenario: And has special treatment when it is the first word of a line
Given some precondition.
And another precondition
… StorEvil would try first to match with “And_another_precondition”, followed by “Given_another_precondition”.
StorEvil supports scenario outlines that allow you to execute the specification for each row of data.
To execute an outline:
- surround the values in your story like this:
<someValue>
- use
Scenario Outline:
rather thanScenario:
. - Put the data to be used for each test case into a row of a table.
The table is separated by pipe characters, and the first row is the names of the parameters, which much match the names of the <fields>
.
(This example is from StorEvil’s executing_outlines_with_example_tables
test fixture)
Story: test
Scenario Outline:
Call a method with <int> and <string>
Examples:
|int|string|
|1|one|
|2|two|
|3|three|
This will invoke the following method three times:
public void Call_a_method_with_intParam_and_stringParam(int intParam, string stringParam)