When step fails.
(pytester)
| 350 | |
| 351 | |
| 352 | def test_step_hooks(pytester): |
| 353 | """When step fails.""" |
| 354 | pytester.makefile( |
| 355 | ".feature", |
| 356 | test=""" |
| 357 | Feature: StepHandler hooks |
| 358 | Scenario: When step has hook on failure |
| 359 | Given I have a bar |
| 360 | When it fails |
| 361 | |
| 362 | Scenario: When step's dependency a has failure |
| 363 | Given I have a bar |
| 364 | When its dependency fails |
| 365 | |
| 366 | Scenario: When step is not found |
| 367 | Given not found |
| 368 | |
| 369 | Scenario: When step validation error happens |
| 370 | Given foo |
| 371 | And foo |
| 372 | """, |
| 373 | ) |
| 374 | pytester.makepyfile( |
| 375 | """ |
| 376 | import pytest |
| 377 | from pytest_bdd import given, when, scenario |
| 378 | |
| 379 | @given('I have a bar') |
| 380 | def _(): |
| 381 | return 'bar' |
| 382 | |
| 383 | @when('it fails') |
| 384 | def _(): |
| 385 | raise Exception('when fails') |
| 386 | |
| 387 | @given('I have a bar') |
| 388 | def _(): |
| 389 | return 'bar' |
| 390 | |
| 391 | @pytest.fixture |
| 392 | def dependency(): |
| 393 | raise Exception('dependency fails') |
| 394 | |
| 395 | @when("its dependency fails") |
| 396 | def _(dependency): |
| 397 | pass |
| 398 | |
| 399 | @scenario('test.feature', "When step's dependency a has failure") |
| 400 | def test_when_dependency_fails(): |
| 401 | pass |
| 402 | |
| 403 | @scenario('test.feature', 'When step has hook on failure') |
| 404 | def test_when_fails(): |
| 405 | pass |
| 406 | |
| 407 | @scenario('test.feature', 'When step is not found') |
| 408 | def test_when_not_found(): |
| 409 | pass |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…