File: issue0457.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 (114 lines) | stat: -rw-r--r-- 3,651 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
@not_reproducible
@issue
Feature: Issue #457 -- Double-quotes in error messages of JUnit XML reports

    STATUS: Problem is currently not reproducible.
    XML attributes are escaped correctly even when double-quotes are used.

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

        @step('{word:w} step fails with message')
        def step_fails(context, word):
            assert context.text
            assert False, "FAILED: "+ context.text

        @step('{word:w} step fails with error and message')
        def step_fails2(context, word):
            assert context.text
            raise RuntimeError(context.text)
        """


    @not.with_python.version=3.8
    Scenario: Use failing assertation in a JUnit XML report
      Given a file named "features/fails1.feature" with:
        """
        Feature:
          Scenario: Alice
            Given a step fails with message:
              '''
              My name is "Alice"
              '''
        """
      When I run "behave --junit features/fails1.feature"
      Then it should fail with:
        """
        0 scenarios passed, 1 failed, 0 skipped
        """
      And the file "reports/TESTS-fails1.xml" should contain:
        """
        <failure message="FAILED: My name is &quot;Alice&quot;"
        """

    @use.with_python.version=3.8
    Scenario: Use failing assertation in a JUnit XML report
      Given a file named "features/fails1.feature" with:
        """
        Feature:
          Scenario: Alice
            Given a step fails with message:
              '''
              My name is "Alice"
              '''
        """
      When I run "behave --junit features/fails1.feature"
      Then it should fail with:
        """
        0 scenarios passed, 1 failed, 0 skipped
        """
      And the file "reports/TESTS-fails1.xml" should contain:
        """
        <failure type="AssertionError" message="FAILED: My name is &quot;Alice&quot;">
        """
        # -- HINT FOR: Python < 3.8
        # <failure message="FAILED: My name is &quot;Alice&quot;"


    @not.with_python.version=3.8
    Scenario: Use exception in a JUnit XML report
      Given a file named "features/fails2.feature" with:
        """
        Feature:
          Scenario: Bob
            Given a step fails with error and message:
              '''
              My name is "Bob" and <here> I am
              '''
        """
      When I run "behave --junit features/fails2.feature"
      Then it should fail with:
        """
        0 scenarios passed, 1 failed, 0 skipped
        """
      And the file "reports/TESTS-fails2.xml" should contain:
        """
        <error message="My name is &quot;Bob&quot; and &lt;here&gt; I am"
        """

    @use.with_python.version=3.8
    Scenario: Use exception in a JUnit XML report
      Given a file named "features/fails2.feature" with:
        """
        Feature:
          Scenario: Bob
            Given a step fails with error and message:
              '''
              My name is "Bob" and <here> I am
              '''
        """
      When I run "behave --junit features/fails2.feature"
      Then it should fail with:
        """
        0 scenarios passed, 1 failed, 0 skipped
        """
      And the file "reports/TESTS-fails2.xml" should contain:
        """
        <error type="RuntimeError" message="My name is &quot;Bob&quot; and &lt;here&gt; I am">
        """
        # -- HINT FOR: Python < 3.8
        # <error message="My name is &quot;Bob&quot; and &lt;here&gt; I am"