File: issue0385.feature

package info (click to toggle)
behave 1.2.6-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,160 kB
  • sloc: python: 19,857; makefile: 137; sh: 18
file content (109 lines) | stat: -rw-r--r-- 3,267 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
@issue
@change_request
Feature: Issue #385 -- before_scenario called too late

    . RATIONALE:
    . Due to:
    .
    .   * skip scenario/feature support in before_scenario (and before_feature) hooks
    .   * active-tags
    .
    . formatters are now called to early (for before feature/scenario functionality).
    . Formatters should be called after the before-hooks are processed.
    .
    . NOTES:
    .  * Test uses show_skipped=false to ensure that at least the
    .    scenario/feature title is shown with plain formatter.

    @setup
    Scenario:
      Given a new working directory
      And a file named "features/steps/pass_steps.py" with:
        """
        from behave import step

        @step('{word:w} step passes')
        def step_passes(context, word):
            pass
        """
      And a file named "features/environment.py" with:
        """
        from __future__ import print_function

        def before_feature(context, feature):
            if "skip" in feature.tags:
                print("SKIP-FEATURE: %s" % feature.name)
                feature.mark_skipped()

        def before_scenario(context, scenario):
            if "skip" in scenario.tags:
                print("SKIP-SCENARIO: %s" % scenario.name)
                scenario.mark_skipped()
        """
      And a file named "behave.ini" with:
        """
        [behave]
        show_skipped = false
        """

    Scenario: Formatter is not called with skip in before_scenario hook
      Given a file named "features/alice.feature" with:
        """
        Feature: Alice

          @skip
          Scenario: Alice and Bob
            Given a step passes

          Scenario: Alice in China
            When another step passes
        """
      When I run "behave -f plain features/alice.feature"
      Then it should pass with:
        """
        1 scenario passed, 0 failed, 1 skipped
        """
      And the command output should contain:
        """
        SKIP-SCENARIO: Alice and Bob

        Scenario: Alice in China
          When another step passes ... passed
        """
      But the command output should not contain:
        """
        Scenario: Alice and Bob
        SKIP-FEATURE: Alice and Bob
        """
      And the command output should not contain "Scenario: Alice and Bob"


    Scenario: Formatter is not called with skip in before_feature hook
      Given a file named "features/bob.feature" with:
        """
        @skip
        Feature: Bob

          Scenario: Bob and Alice
            Given a step passes

          Scenario: Bob in China
            When another step passes
        """
      When I run "behave -f plain features/bob.feature"
      Then it should pass with:
        """
        SKIP-FEATURE: Bob

        0 features passed, 0 failed, 1 skipped
        0 scenarios passed, 0 failed, 2 skipped
        """
      But the command output should not contain:
        """
        Feature: Bob
        SKIP-FEATURE: Bob
        """
      And the command output should not contain "Feature: Bob"
      And the command output should not contain "Scenario: Bob and Alice"
      And the command output should not contain "Scenario: Bob in China"
      And note that "all scenarios of the feature are also skipped"