| 1 |
@issue |
| 2 |
Feature: Issue #67: JSON formatter cannot serialize tables. |
| 3 |
|
| 4 |
The JSON formatter cannot handle tables (currently): |
| 5 |
|
| 6 |
* Table as setup/intermediate/result table in steps of scenario |
| 7 |
* Examples tables in a ScenarioOutline |
| 8 |
|
| 9 |
A JSON exception occurs when such a feature file should be processed. |
| 10 |
|
| 11 |
|
| 12 |
Scenario: Scenario with Tables |
| 13 |
Given a new working directory |
| 14 |
And a file named "features/steps/steps1.py" with: |
| 15 |
""" |
| 16 |
from behave import given, when, then |
| 17 |
|
| 18 |
@given(u'I add the following employees') |
| 19 |
def step(context): |
| 20 |
pass # -- SKIP: Table processing here. |
| 21 |
|
| 22 |
@when(u'I select department "{department}"') |
| 23 |
def step(context, department): |
| 24 |
context.department = department |
| 25 |
|
| 26 |
@then(u'I get the following employees') |
| 27 |
def step(context): |
| 28 |
pass # -- SKIP: Table processing here. |
| 29 |
""" |
| 30 |
And a file named "features/issue67_case1.feature" with: |
| 31 |
""" |
| 32 |
Feature: Scenario with Tables |
| 33 |
Scenario: |
| 34 |
Given I add the following employees: |
| 35 |
| name | department | |
| 36 |
| Alice | Wonderland | |
| 37 |
| Bob | Moonwalk | |
| 38 |
When I select department "Wonderland" |
| 39 |
Then I get the following employees: |
| 40 |
| name | department | |
| 41 |
| Alice | Wonderland | |
| 42 |
""" |
| 43 |
When I run "behave -f json features/issue67_case1.feature" |
| 44 |
Then it should pass with: |
| 45 |
""" |
| 46 |
1 scenario passed, 0 failed, 0 skipped |
| 47 |
3 steps passed, 0 failed, 0 skipped, 0 undefined |
| 48 |
""" |
| 49 |
But the command output should not contain: |
| 50 |
""" |
| 51 |
TypeError: <Row [u'Alice', u'Wonderland']> is not JSON serializable |
| 52 |
""" |
| 53 |
|
| 54 |
Scenario: ScenarioOutline with Examples Table |
| 55 |
Given a file named "features/steps/steps2.py" with: |
| 56 |
""" |
| 57 |
from behave import given, when, then |
| 58 |
|
| 59 |
@given(u'a step with "{name}"') |
| 60 |
def step(context, name): |
| 61 |
context.name = name |
| 62 |
|
| 63 |
@when(u'a step with "{name}" occurs') |
| 64 |
def step(context, name): |
| 65 |
assert context.name == name |
| 66 |
|
| 67 |
@then(u'a step with "{name}" is reached') |
| 68 |
def step(context, name): |
| 69 |
assert context.name == name |
| 70 |
""" |
| 71 |
And a file named "features/issue67_case2.feature" with: |
| 72 |
""" |
| 73 |
Feature: ScenarioOutline with Examples Table |
| 74 |
Scenario Outline: |
| 75 |
Given a step with "<name>" |
| 76 |
When a step with "<name>" occurs |
| 77 |
Then a step with "<name>" is reached |
| 78 |
|
| 79 |
Examples: |
| 80 |
|name | |
| 81 |
|Alice| |
| 82 |
|Bob | |
| 83 |
""" |
| 84 |
When I run "behave -f json features/issue67_case2.feature" |
| 85 |
Then it should pass with: |
| 86 |
""" |
| 87 |
2 scenarios passed, 0 failed, 0 skipped |
| 88 |
6 steps passed, 0 failed, 0 skipped, 0 undefined |
| 89 |
""" |
| 90 |
|