-
Notifications
You must be signed in to change notification settings - Fork 5
/
README
186 lines (138 loc) · 6.69 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
SpecSalad
-Writing SpecFlow specifications without writing step definitions
-A C# 4.0 implementation for SpecFlow of the Cucumber addon, CukeSalad,
by Antony Marcano and Riverglide.com
SpecSalad allows the developer to write SpecFlow specifications without having to
write step definitions, avoiding the problems of maintaining large step definition
files which are hard to maintain and navigate through. Instead, the idea of tasks
is used to identify what needs to be done and roles those who will do them. This
approach splits the implementation of the tests into manageable chunks, making
them easy to maintain and navigate.
---------------------------------------------------------------------------------
Language Summary
(Given | And) there is (?<role>.*)
(When | And) the (?<role>.*) (attempts to | was able to | were able to | did)
(?<task>.*)
( [,:]
(?<single_value>.*)
|
( (?<name>.*) '(?<value>.*)'
( (,)? (?<name>.*) '(?<value>.*)' )*
)+
)?
(Then | And) the (?<role>.*) should (?<task>.*) '(?<expected_answer>.*)'
(Then | And) the (?<role>.*) should (?<task>.*) that includes: (?<expected_content>.*)
(Then | And) the (?<role>.*) should (?<task>.*)
To define a task, the implementation class must implement SpecSalad.ApplicationTask
abstract class
To define a role, the class must inherit from SpecSalad.ApplicationRole
---------------------------------------------------------------------------------
INSTALLATION
INSTALLATION
SpecSalad is available as a Nuget package which installs all the required
dependencies (SpecFlow and NUnit) and inserts the assembly reference into the app
config file of the test project.
It can also be installed manually by compiling the production source, adding a
reference to the SpecSalad, SpecFlow, NUnit and adding the following lines to the
app config file created by SpecFlow
<stepAssemblies>
<stepAssembly assembly="SpecSalad" />
</stepAssemblies>
USING SPECSALAD
SpecSalad enhances the Gurkin language with formal text to allow parsing of the
features from a human readable narative. The description of this formalism uses
the following convention (RegEx) for brevity:
(a|b|..) - Required value alternatives where an empty side means
optional
(a|b|..)? - Optional value alternatives group of values alternatives
a? - Optional value
(?<name>.*) - Identifies named value that will be captured for test
construction
--GIVEN SYNTAX--
Given (I am | you are) (a|an) (?<role>.*)
All SpecSalad scenarios start with a Given that defines the ROLE performing that
scenario. For example,
Given I am a SpecSalad developer
Given I am an Administrator
Given you are a SpecSalad developer
Given you are an Administrator
Subsequently, one or more tasks can be called to setup the environment for the
scenario.
And (I | you) (attempt to | was able to | were able to | did)
(?<task>.*)
( [,:]
(?<single_value>.*)
|
( (?<name>.*) '(?<value>.*)'
( (,)? (?<name>.*) '(?<value>.*)' )*
)+
)?
And I attempt to start the calculator
And I attempt to add the number: 1
And I attempt to add the number: first number '1'
And I attempt to add the numbers: first number '1', second number '2', third number '3'
--WHEN SYNTAX--
As above When allows for one or more tasks to be called, the syntax is exactly
the same as the above And step.
(When | And) (I | you) (attempt to | was able to | were able to | did)
(?<task>.*)
( [,:]
(?<single_value>.*)
|
( (?<name>.*) '(?<value>.*)'
( (,)? (?<name>.*) '(?<value>.*)' )*
)+
)?
When I did add numbers together: first number '1' second number '2'
And I attempt to subtract the numbers: first number '2' second number '1'
--THEN SYNTAX--
Asserts that the named task returns the expected answer using the Assert.Equals
comparison function
(Then | And) (I | you) should (?<task>.*) '(?<expected_answer>.*)'
Then I should see the result number '5'
Asserts that the task returns a collection that contains the expected content
item using the Assert.Contains comparison function
(Then | And) (I | you) should (?<task>.*) that includes: (?<expected_content>.*)
Then I should see on the screen text that includes: Hello World
The following syntax doesn't carry out any assert, but expects the task to do some
custom comparison
(Then | And) (I | you) should (?<task>.*)
Then I should see correct result of some kind
For scenarios with multiple roles, an additional syntax is available that allows the
developer to map the role to the step. These steps are identical to the above with
the addition of a role name.
(Given | And) there is a (?<role>.*)
(When | And) the (?<role>.*) (attempts to | was able to | were able to | did)
(?<task>.*)
( [,:]
(?<single_value>.*)
|
( (?<name>.*) '(?<value>.*)'
( (,)? (?<name>.*) '(?<value>.*)' )*
)+
)?
(Then | And) the (?<role>.*) should (?<task>.*) '(?<expected_answer>.*)'
(Then | And) the (?<role>.*) should (?<task>.*) that includes: (?<expected_content>.*)
(Then | And) the (?<role>.*) should (?<task>.*)
If multiple roles are defined in the scenario, and a step without a defined role
is called then the first role defined in the scenario is used by default.
TASK
To define a task, the implementation class must implement SpecSalad.ApplicationTask
abstract class, which defines the following functionality.
Perform_Task:
This method must be overridden, it is here that the role is called to carry
out the specific task
Role
provides access to the current scenario role
Details
This object contains all the parameters provided in the scenario step, there
are two methods for extracting the stored data
Value() - returns the first data items value which, by definition
of the language, will be the first (?<role>.*)
Value_Of(key) - returns the value of the given key
Role
To define a role, the class must inherit from SpecSalad.ApplicationRole, this
base class provides the following additional functionality.
StoreValue(key, value) - stores for the duration of the scenario a value
with a given key
Retrieve(key) - returns a previously stored value