Debian Codegraph @

features/parser.feature.sad_cases.feature

raw
1 Feature: Parsing a Feature File without a Feature or with several Features
2
3
4 @setup
5 Scenario: Feature Setup
6 Given a new working directory
7 And an empty file named "features/steps/empty_steps.py"
8 And a file named "features/steps/passing_steps.py" with:
9 """
10 from behave import step
11
12 @step('a step passes')
13 def step_passes(context):
14 pass
15 """
16
17 @no_feature
18 Scenario: Empty Feature File
19 Given an empty file named "features/empty.feature"
20 When I run "behave -f plain features/empty.feature"
21 Then it should pass with:
22 """
23 0 features passed, 0 failed, 0 skipped
24 0 scenarios passed, 0 failed, 0 skipped
25 0 steps passed, 0 failed, 0 skipped, 0 undefined
26 """
27
28
29 @no_feature
30 Scenario: Feature File without Feature, only with Comments
31 Given a file named "features/only_comments.feature" with:
32 """
33 # COMMENT: Comment starts at begin of line.
34 # INDENTED-COMMENT: Comment starts after some whitespace.
35 """
36 When I run "behave -f plain features/only_comments.feature"
37 Then it should pass with:
38 """
39 0 features passed, 0 failed, 0 skipped
40 0 scenarios passed, 0 failed, 0 skipped
41 0 steps passed, 0 failed, 0 skipped, 0 undefined
42 """
43
44
45 @no_feature
46 Scenario: Feature File without Feature, only with Empty Lines
47 Given a file named "features/only_empty_lines.feature" with:
48 """
49
50 """
51 When I run "behave -f plain features/only_empty_lines.feature"
52 Then it should pass with:
53 """
54 0 features passed, 0 failed, 0 skipped
55 0 scenarios passed, 0 failed, 0 skipped
56 0 steps passed, 0 failed, 0 skipped, 0 undefined
57 """
58
59
60 @no_feature
61 Scenario: Feature File without Feature, only with Tags
62 Given a file named "features/only_tags.feature" with:
63 """
64 @weird
65 @no_feature
66 """
67 When I run "behave -f plain features/only_tags.feature"
68 Then it should pass with:
69 """
70 0 features passed, 0 failed, 0 skipped
71 0 scenarios passed, 0 failed, 0 skipped
72 0 steps passed, 0 failed, 0 skipped, 0 undefined
73 """
74
75 @no_feature
76 @parser.with_parse_error
77 Scenario: Feature File with Text
78 Given a file named "features/only_text.feature" with:
79 """
80 This File: Contains only text without keywords.
81 OOPS.
82 """
83 When I run "behave -f plain features/only_text.feature"
84 Then it should fail with:
85 """
86 Failed to parse "{__WORKDIR__}/features/only_text.feature":
87 Parser failure in state init, at line 1: "This File: Contains only text without keywords."
88 REASON: No feature found.
89 """
90
91
92 @no_feature
93 @parser.with_parse_error
94 Scenario: Feature File with Scenario, but without Feature keyword
95 Given a file named "features/naked_scenario_only.feature" with:
96 """
97 Scenario:
98 Given a step passes
99 When a step passes
100 Then a step passes
101 """
102 When I run "behave -f plain features/naked_scenario_only.feature"
103 Then it should fail with:
104 """
105 Failed to parse "{__WORKDIR__}/features/naked_scenario_only.feature":
106 Parser failure in state init, at line 1: "Scenario:"
107 REASON: Scenario may not occur before Feature.
108 """
109
110
111 @many_features
112 @parser.with_parse_error
113 Scenario: Feature file with 2 features
114
115 NOTE: Gherkin parser supports only one feature per feature file.
116
117 Given a file named "features/steps/passing_steps.py" with:
118 """
119 from behave import step
120
121 @step('a step passes')
122 def step_passes(context):
123 pass
124 """
125 And a file named "features/two_features.feature" with:
126 """
127 Feature: F1
128 Scenario: F1.1
129 Given a step passes
130 When a step passes
131 Then a step passes
132
133 Feature: F2
134 Scenario: F2.1
135 Given a step passes
136 Then a step passes
137 """
138 When I run "behave -f plain features/two_features.feature"
139 Then it should fail with:
140 """
141 Failed to parse "{__WORKDIR__}/features/two_features.feature":
142 Parser failure in state steps, at line 7: "Feature: F2"
143 REASON: Multiple features in one file are not supported.
144 """