File: issue0067.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 (90 lines) | stat: -rw-r--r-- 2,781 bytes parent folder | download | duplicates (4)
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
@issue
Feature: Issue #67: JSON formatter cannot serialize tables.

  The JSON formatter cannot handle tables (currently):

    * Table as setup/intermediate/result table in steps of scenario
    * Examples tables in a ScenarioOutline

  A JSON exception occurs when such a feature file should be processed.


  Scenario: Scenario with Tables
    Given a new working directory
    And   a file named "features/steps/steps1.py" with:
      """
      from behave import given, when, then

      @given(u'I add the following employees')
      def step(context):
          pass  # -- SKIP: Table processing here.

      @when(u'I select department "{department}"')
      def step(context, department):
          context.department = department

      @then(u'I get the following employees')
      def step(context):
          pass  # -- SKIP: Table processing here.
      """
    And  a file named "features/issue67_case1.feature" with:
      """
      Feature: Scenario with Tables
        Scenario:
         Given I add the following employees:
            | name      | department  |
            | Alice     | Wonderland  |
            | Bob       | Moonwalk    |
          When I select department "Wonderland"
          Then I get the following employees:
            | name      | department  |
            | Alice     | Wonderland  |
      """
    When I run "behave -f json features/issue67_case1.feature"
    Then it should pass with:
      """
      1 scenario passed, 0 failed, 0 skipped
      3 steps passed, 0 failed, 0 skipped, 0 undefined
      """
    But the command output should not contain:
      """
      TypeError: <Row [u'Alice', u'Wonderland']> is not JSON serializable
      """

  Scenario: ScenarioOutline with Examples Table
    Given a file named "features/steps/steps2.py" with:
      """
      from behave import given, when, then

      @given(u'a step with "{name}"')
      def step(context, name):
          context.name = name

      @when(u'a step with "{name}" occurs')
      def step(context, name):
          assert context.name == name

      @then(u'a step with "{name}" is reached')
      def step(context, name):
          assert context.name == name
      """
    And a file named "features/issue67_case2.feature" with:
      """
      Feature: ScenarioOutline with Examples Table
        Scenario Outline:
          Given a step with "<name>"
          When  a step with "<name>" occurs
          Then  a step with "<name>" is reached

        Examples:
            |name |
            |Alice|
            |Bob  |
      """
    When I run "behave -f json features/issue67_case2.feature"
    Then it should pass with:
      """
      2 scenarios passed, 0 failed, 0 skipped
      6 steps passed, 0 failed, 0 skipped, 0 undefined
      """