Skip to content

Commit edb1108

Browse files
committed
Add Scenario Outline
1 parent ca51ed1 commit edb1108

28 files changed

Lines changed: 424 additions & 122 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.2.0] - Scenario Outline
2+
3+
* Add scenario outline support
4+
15
## [1.1.0] - Integration tests
26

37
* Add support for integration tests

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Feature: Counter
7171
Then I see {'1'} text
7272
```
7373

74-
`Backround` and `After` keywords are optional. A `Background` allows you to add some context to the scenarios that follow it. It can contain one or more Given steps, which are run before each scenario. An `After` scenarion run even if a test fails, to ensure that it has a chance to clean up after itself. Most probably you don't need to use this keyword.
74+
`Backround` and `After` sections are optional. A `Background` allows you to add some context to the scenarios that follow it. It can contain one or more Given steps, which are run before each scenario. An `After` scenarion run even if a test fails, to ensure that it has a chance to clean up after itself. Most probably you don't need to use this keyword.
7575

7676
Each feature file must have one or more `Feature:`s. Features become test groups in Flutter tests.
7777

@@ -80,6 +80,28 @@ Each feature group must have one or more `Scenario:`s (or `Example:`s). Scenario
8080
Each scenario must have one or more lines with steps. Each of them must start with `Given`, `When`, `Then`, `And`, or `But` keywords. Conventionally `Given` steps are used for test arrangements, `When` — for interaction, `Then` — for asserts. Keywords are not taken into account when looking for a step definition.
8181
You can have as many steps as you like, but it's recommended you keep the number at 3-5 per scenario. Having too many steps will cause it to lose it’s expressive power as specification and documentation.
8282

83+
The `Scenario Outline` keyword can be used to run the same `Scenario` multiple times, with different combinations of values.
84+
85+
A Scenario Outline must contain an `Examples` (or `Scenarios`) section. Its steps are interpreted as a template which is never directly run. Instead, the Scenario Outline is run once for each row in the Examples section beneath it (not counting the first header row).
86+
87+
The steps can use `<>` delimited parameters that reference headers in the examples table. The plugin will replace these parameters with values from the table before it tries to match the step against a step definition.
88+
89+
Scenario Outline example:
90+
```ruby
91+
Feature: Sample
92+
93+
Scenario Outline: Plus button increases the counter
94+
Given the app is running
95+
When I tap {Icons.add} icon <times> times
96+
Then I see <result> text
97+
98+
Examples:
99+
| times | result |
100+
| 0 | '0' |
101+
| 1 | '1' |
102+
| 42 | '42' |
103+
```
104+
83105
## Predefined steps
84106

85107
This library comes with a list of predefined steps. They will be auto-generated for you, but you may want to adjust their implementation according to your needs.

example/integration_test/sample_test.dart

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/pubspec.lock

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ packages:
77
name: _fe_analyzer_shared
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "21.0.0"
10+
version: "26.0.0"
1111
analyzer:
1212
dependency: transitive
1313
description:
1414
name: analyzer
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "1.5.0"
17+
version: "2.3.0"
1818
archive:
1919
dependency: transitive
2020
description:
@@ -28,21 +28,21 @@ packages:
2828
name: args
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "2.1.0"
31+
version: "2.3.0"
3232
async:
3333
dependency: transitive
3434
description:
3535
name: async
3636
url: "https://pub.dartlang.org"
3737
source: hosted
38-
version: "2.6.1"
38+
version: "2.8.1"
3939
bdd_widget_test:
4040
dependency: "direct dev"
4141
description:
4242
path: ".."
4343
relative: true
4444
source: path
45-
version: "1.1.0"
45+
version: "1.2.0"
4646
boolean_selector:
4747
dependency: transitive
4848
description:
@@ -56,7 +56,7 @@ packages:
5656
name: build
5757
url: "https://pub.dartlang.org"
5858
source: hosted
59-
version: "2.0.1"
59+
version: "2.1.0"
6060
build_config:
6161
dependency: transitive
6262
description:
@@ -77,35 +77,35 @@ packages:
7777
name: build_resolvers
7878
url: "https://pub.dartlang.org"
7979
source: hosted
80-
version: "2.0.1"
80+
version: "2.0.4"
8181
build_runner:
8282
dependency: "direct dev"
8383
description:
8484
name: build_runner
8585
url: "https://pub.dartlang.org"
8686
source: hosted
87-
version: "2.0.1"
87+
version: "2.1.2"
8888
build_runner_core:
8989
dependency: transitive
9090
description:
9191
name: build_runner_core
9292
url: "https://pub.dartlang.org"
9393
source: hosted
94-
version: "7.0.0"
94+
version: "7.1.0"
9595
built_collection:
9696
dependency: transitive
9797
description:
9898
name: built_collection
9999
url: "https://pub.dartlang.org"
100100
source: hosted
101-
version: "5.0.0"
101+
version: "5.1.1"
102102
built_value:
103103
dependency: transitive
104104
description:
105105
name: built_value
106106
url: "https://pub.dartlang.org"
107107
source: hosted
108-
version: "8.0.5"
108+
version: "8.1.2"
109109
characters:
110110
dependency: transitive
111111
description:
@@ -119,7 +119,7 @@ packages:
119119
name: charcode
120120
url: "https://pub.dartlang.org"
121121
source: hosted
122-
version: "1.2.0"
122+
version: "1.3.1"
123123
checked_yaml:
124124
dependency: transitive
125125
description:
@@ -133,7 +133,7 @@ packages:
133133
name: cli_util
134134
url: "https://pub.dartlang.org"
135135
source: hosted
136-
version: "0.3.0"
136+
version: "0.3.4"
137137
clock:
138138
dependency: transitive
139139
description:
@@ -147,7 +147,7 @@ packages:
147147
name: code_builder
148148
url: "https://pub.dartlang.org"
149149
source: hosted
150-
version: "4.0.0"
150+
version: "4.1.0"
151151
collection:
152152
dependency: transitive
153153
description:
@@ -161,7 +161,7 @@ packages:
161161
name: convert
162162
url: "https://pub.dartlang.org"
163163
source: hosted
164-
version: "3.0.0"
164+
version: "3.0.1"
165165
crypto:
166166
dependency: transitive
167167
description:
@@ -175,7 +175,7 @@ packages:
175175
name: dart_style
176176
url: "https://pub.dartlang.org"
177177
source: hosted
178-
version: "2.0.0"
178+
version: "2.2.0"
179179
fake_async:
180180
dependency: transitive
181181
description:
@@ -189,7 +189,7 @@ packages:
189189
name: file
190190
url: "https://pub.dartlang.org"
191191
source: hosted
192-
version: "6.1.0"
192+
version: "6.1.2"
193193
fixnum:
194194
dependency: transitive
195195
description:
@@ -212,6 +212,13 @@ packages:
212212
description: flutter
213213
source: sdk
214214
version: "0.0.0"
215+
frontend_server_client:
216+
dependency: transitive
217+
description:
218+
name: frontend_server_client
219+
url: "https://pub.dartlang.org"
220+
source: hosted
221+
version: "2.1.2"
215222
fuchsia_remote_debug_protocol:
216223
dependency: transitive
217224
description: flutter
@@ -223,14 +230,14 @@ packages:
223230
name: glob
224231
url: "https://pub.dartlang.org"
225232
source: hosted
226-
version: "2.0.1"
233+
version: "2.0.2"
227234
graphs:
228235
dependency: transitive
229236
description:
230237
name: graphs
231238
url: "https://pub.dartlang.org"
232239
source: hosted
233-
version: "2.0.0"
240+
version: "2.1.0"
234241
http_multi_server:
235242
dependency: transitive
236243
description:
@@ -256,7 +263,7 @@ packages:
256263
name: io
257264
url: "https://pub.dartlang.org"
258265
source: hosted
259-
version: "1.0.0"
266+
version: "1.0.3"
260267
js:
261268
dependency: transitive
262269
description:
@@ -270,14 +277,14 @@ packages:
270277
name: json_annotation
271278
url: "https://pub.dartlang.org"
272279
source: hosted
273-
version: "4.0.1"
280+
version: "4.1.0"
274281
logging:
275282
dependency: transitive
276283
description:
277284
name: logging
278285
url: "https://pub.dartlang.org"
279286
source: hosted
280-
version: "1.0.1"
287+
version: "1.0.2"
281288
matcher:
282289
dependency: transitive
283290
description:
@@ -291,7 +298,7 @@ packages:
291298
name: meta
292299
url: "https://pub.dartlang.org"
293300
source: hosted
294-
version: "1.3.0"
301+
version: "1.7.0"
295302
mime:
296303
dependency: transitive
297304
description:
@@ -305,7 +312,7 @@ packages:
305312
name: package_config
306313
url: "https://pub.dartlang.org"
307314
source: hosted
308-
version: "2.0.0"
315+
version: "2.0.2"
309316
path:
310317
dependency: transitive
311318
description:
@@ -319,7 +326,7 @@ packages:
319326
name: pedantic
320327
url: "https://pub.dartlang.org"
321328
source: hosted
322-
version: "1.11.0"
329+
version: "1.11.1"
323330
platform:
324331
dependency: transitive
325332
description:
@@ -340,28 +347,28 @@ packages:
340347
name: process
341348
url: "https://pub.dartlang.org"
342349
source: hosted
343-
version: "4.2.1"
350+
version: "4.2.3"
344351
pub_semver:
345352
dependency: transitive
346353
description:
347354
name: pub_semver
348355
url: "https://pub.dartlang.org"
349356
source: hosted
350-
version: "2.0.0"
357+
version: "2.1.0"
351358
pubspec_parse:
352359
dependency: transitive
353360
description:
354361
name: pubspec_parse
355362
url: "https://pub.dartlang.org"
356363
source: hosted
357-
version: "1.0.0"
364+
version: "1.1.0"
358365
shelf:
359366
dependency: transitive
360367
description:
361368
name: shelf
362369
url: "https://pub.dartlang.org"
363370
source: hosted
364-
version: "1.1.1"
371+
version: "1.2.0"
365372
shelf_web_socket:
366373
dependency: transitive
367374
description:
@@ -429,7 +436,7 @@ packages:
429436
name: test_api
430437
url: "https://pub.dartlang.org"
431438
source: hosted
432-
version: "0.3.0"
439+
version: "0.4.2"
433440
timing:
434441
dependency: transitive
435442
description:
@@ -457,21 +464,21 @@ packages:
457464
name: vm_service
458465
url: "https://pub.dartlang.org"
459466
source: hosted
460-
version: "6.2.0"
467+
version: "7.1.1"
461468
watcher:
462469
dependency: transitive
463470
description:
464471
name: watcher
465472
url: "https://pub.dartlang.org"
466473
source: hosted
467-
version: "1.0.0"
474+
version: "1.0.1"
468475
web_socket_channel:
469476
dependency: transitive
470477
description:
471478
name: web_socket_channel
472479
url: "https://pub.dartlang.org"
473480
source: hosted
474-
version: "2.0.0"
481+
version: "2.1.0"
475482
webdriver:
476483
dependency: transitive
477484
description:
@@ -487,4 +494,4 @@ packages:
487494
source: hosted
488495
version: "3.1.0"
489496
sdks:
490-
dart: ">=2.12.0 <3.0.0"
497+
dart: ">=2.14.0 <3.0.0"

example/test/sample.feature

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Feature: Counter
44
Given the app is running
55

66
After:
7-
# Just for the demo purpose, you may write "I don't see {'42'} text" to use built-in step instead.
7+
# Just for the demo purpose, you may write "I don't see {'surprise'} text" to use built-in step instead.
88
# See the list of built-in step below.
9-
And I do not see {'42'} text
9+
And I do not see {'surprise'} text
1010

1111
# @testMethodName: testGoldens
1212
Scenario: Initial counter value is 0
@@ -16,6 +16,17 @@ Feature: Counter
1616
When I tap {Icons.add} icon
1717
Then I see {'1'} text
1818

19+
Scenario Outline: Plus button increases the counter
20+
Given the app is running
21+
When I tap {Icons.add} icon <times> times
22+
Then I see <result> text
23+
24+
Examples:
25+
| times | result |
26+
| 0 | '0' |
27+
| 1 | '1' |
28+
| 42 | '42' |
29+
1930
# Scenario: Built-in steps
2031
# And I don't see {Icons.add} icon
2132
# And I don't see {'text'} rich text

0 commit comments

Comments
 (0)