Test first step using incorrect initial keyword.
(pytester)
| 216 | |
| 217 | |
| 218 | def test_improper_initial_keyword(pytester): |
| 219 | """Test first step using incorrect initial keyword.""" |
| 220 | features = pytester.mkdir("features") |
| 221 | features.joinpath("test.feature").write_text( |
| 222 | textwrap.dedent( |
| 223 | """ |
| 224 | Feature: Incorrect initial keyword |
| 225 | |
| 226 | Scenario: No initial Given, When or Then |
| 227 | And foo |
| 228 | """ |
| 229 | ), |
| 230 | encoding="utf-8", |
| 231 | ) |
| 232 | pytester.makepyfile( |
| 233 | textwrap.dedent( |
| 234 | """ |
| 235 | from pytest_bdd import given, scenarios |
| 236 | |
| 237 | scenarios('features') |
| 238 | |
| 239 | @given("foo") |
| 240 | def foo(): |
| 241 | pass |
| 242 | |
| 243 | @then("bar") |
| 244 | def bar(): |
| 245 | pass |
| 246 | """ |
| 247 | ) |
| 248 | ) |
| 249 | |
| 250 | result = pytester.runpytest() |
| 251 | result.stdout.fnmatch_lines( |
| 252 | ["*StepError: First step in a scenario or background must start with 'Given', 'When' or 'Then', but got And.*"] |
| 253 | ) |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…