Debian Codegraph @

features/step_dialect.given_when_then.feature

raw
1 Feature: Step Dialect for BDD Steps with Given/When/Then Keywords
2
3 In order to execute a sequence of steps with BDD keywords (Given/When/Then)
4 As a test/story writer
5 I want to have the possibility to express myself.
6
7 . NOTE:
8 . * More details are provided in other features.
9
10
11 Scenario: Simple example
12
13 Normally preferred style with BDD keywords.
14 Note that BDD keywords are dependent on language settings.
15
16 Given a step passes
17 When a step passes
18 And a step passes
19 Then a step passes
20 And a step passes
21 But a step passes
22
23
24 Scenario: Simple example (with lower-case keywords)
25
26 Alternative style with lower-case BDD keywords.
27
28 given a step passes
29 when a step passes
30 and a step passes
31 then a step passes
32 and a step passes
33 but a step passes
34
35
36 Scenario: Step usage example with details by running behave
37 Given a new working directory
38 And a file named "features/steps/steps.py" with:
39 """
40 from behave import given, when, then, step
41
42 @given('a step passes')
43 def given_step_passes(context):
44 pass
45
46 @when('a step passes')
47 def when_step_passes(context):
48 pass
49
50 @then('a step passes')
51 def then_step_passes(context):
52 pass
53
54 @step('a step passes with "{param}"')
55 def step_passes_with_param(context, param):
56 pass
57
58 @step('another step passes')
59 def step_passes(context):
60 pass
61
62 @step('another step passes with "{param}"')
63 def step_passes(context, param):
64 pass
65 """
66 And a file named "features/basic_steps.feature" with:
67 """
68 Feature:
69 Scenario:
70 Given a step passes
71 And another step passes
72 When a step passes with "Alice"
73 Then another step passes with "Bob"
74 """
75 When I run "behave -f plain -T features/basic_steps.feature"
76 Then it should pass with:
77 """
78 1 scenario passed, 0 failed, 0 skipped
79 4 steps passed, 0 failed, 0 skipped
80 """
81 And the command output should contain:
82 """
83 Feature:
84 Scenario:
85 Given a step passes ... passed
86 And another step passes ... passed
87 When a step passes with "Alice" ... passed
88 Then another step passes with "Bob" ... passed
89 """