File: parser.feature.sad_cases.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 (144 lines) | stat: -rw-r--r-- 4,615 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
Feature: Parsing a Feature File without a Feature or with several Features


    @setup
    Scenario: Feature Setup
      Given a new working directory
      And an empty file named "features/steps/empty_steps.py"
      And a file named "features/steps/passing_steps.py" with:
        """
        from behave import step

        @step('a step passes')
        def step_passes(context):
            pass
        """

    @no_feature
    Scenario: Empty Feature File
      Given an empty file named "features/empty.feature"
      When I run "behave -f plain features/empty.feature"
      Then it should pass with:
          """
          0 features passed, 0 failed, 0 skipped
          0 scenarios passed, 0 failed, 0 skipped
          0 steps passed, 0 failed, 0 skipped, 0 undefined
          """


    @no_feature
    Scenario: Feature File without Feature, only with Comments
      Given a file named "features/only_comments.feature" with:
        """
        # COMMENT: Comment starts at begin of line.
            # INDENTED-COMMENT: Comment starts after some whitespace.
        """
      When I run "behave -f plain features/only_comments.feature"
      Then it should pass with:
        """
        0 features passed, 0 failed, 0 skipped
        0 scenarios passed, 0 failed, 0 skipped
        0 steps passed, 0 failed, 0 skipped, 0 undefined
        """


    @no_feature
    Scenario: Feature File without Feature, only with Empty Lines
      Given a file named "features/only_empty_lines.feature" with:
        """

        """
      When I run "behave -f plain features/only_empty_lines.feature"
      Then it should pass with:
        """
        0 features passed, 0 failed, 0 skipped
        0 scenarios passed, 0 failed, 0 skipped
        0 steps passed, 0 failed, 0 skipped, 0 undefined
        """


    @no_feature
    Scenario: Feature File without Feature, only with Tags
      Given a file named "features/only_tags.feature" with:
        """
        @weird
        @no_feature
        """
      When I run "behave -f plain features/only_tags.feature"
      Then it should pass with:
        """
        0 features passed, 0 failed, 0 skipped
        0 scenarios passed, 0 failed, 0 skipped
        0 steps passed, 0 failed, 0 skipped, 0 undefined
        """

    @no_feature
    @parser.with_parse_error
    Scenario: Feature File with Text
      Given a file named "features/only_text.feature" with:
        """
        This File: Contains only text without keywords.
        OOPS.
        """
      When I run "behave -f plain features/only_text.feature"
      Then it should fail with:
        """
        Failed to parse "{__WORKDIR__}/features/only_text.feature":
        Parser failure in state init, at line 1: "This File: Contains only text without keywords."
        REASON: No feature found.
        """


    @no_feature
    @parser.with_parse_error
    Scenario: Feature File with Scenario, but without Feature keyword
      Given a file named "features/naked_scenario_only.feature" with:
        """
          Scenario:
            Given a step passes
            When a step passes
            Then a step passes
        """
      When I run "behave -f plain features/naked_scenario_only.feature"
      Then it should fail with:
        """
        Failed to parse "{__WORKDIR__}/features/naked_scenario_only.feature":
        Parser failure in state init, at line 1: "Scenario:"
        REASON: Scenario may not occur before Feature.
        """


    @many_features
    @parser.with_parse_error
    Scenario: Feature file with 2 features

       NOTE: Gherkin parser supports only one feature per feature file.

          Given a file named "features/steps/passing_steps.py" with:
            """
            from behave import step

            @step('a step passes')
            def step_passes(context):
                pass
            """
          And a file named "features/two_features.feature" with:
            """
            Feature: F1
              Scenario: F1.1
                Given a step passes
                When a step passes
                Then a step passes

            Feature: F2
              Scenario: F2.1
                Given a step passes
                Then a step passes
            """
          When I run "behave -f plain features/two_features.feature"
          Then it should fail with:
            """
            Failed to parse "{__WORKDIR__}/features/two_features.feature":
            Parser failure in state steps, at line 7: "Feature: F2"
            REASON: Multiple features in one file are not supported.
            """