Skip to content

Commit

Permalink
Improve features in etalon tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dpakach committed Jan 16, 2020
1 parent 7505014 commit 09ffcd4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 43 deletions.
7 changes: 0 additions & 7 deletions src/Behat/Gherkin/Loader/YamlFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ public function load($path)
$filename = $this->findRelativePath($path);

return array_map(function (FeatureNode $feature) use ($filename) {
if ($feature->getBackground() !== null && $feature->getBackground()->hasExamples()) {
foreach ($feature->getScenarios() as $scenario) {
if ($scenario instanceof OutlineNode && !$scenario->hasExamples()){
$scenario->setExampleTable($feature->getBackground()->getExamples());
}
}
}
return new FeatureNode(
$feature->getTitle(),
$feature->getDescription(),
Expand Down
19 changes: 8 additions & 11 deletions tests/Behat/Gherkin/Fixtures/etalons/background_with_outline.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
feature:
title: Feature with background and example
title: Feature with example in the background
language: en
line: 1
description: ~
Expand All @@ -11,21 +11,18 @@ feature:
examples:
6: [login, password]
7: ['', '']
8: [unknown_user, '']
8: [unknown_user, 'known_pass']

scenarios:
-
type: outline
title: ~
title: Scenario outline without example table
line: 10
steps:
- { keyword_type: 'Given', type: 'Given', text: 'a failing step', line: 11 }
- { keyword_type: 'Given', type: 'Given', text: 'I browse to the login page', line: 11 }
- { keyword_type: 'When', type: 'When', text: 'I fill in "login" with "<login>"', line: 12 }
- { keyword_type: 'When', type: 'And', text: 'I fill in "password" with "<password>"', line: 13 }
arguments:
-
type: table
rows:
6: [ login, password ]
7: [ '' , '' ]
8: [ unknown_user , '' ]
examples:
6: [login, password]
7: ['', '']
8: [unknown_user, 'known_pass']
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
feature:
title: Feature with background and example
title: Feature with example in background and multiple scenarios
language: en
line: 1
description: ~
Expand All @@ -11,35 +11,35 @@ feature:
examples:
6: [login, password]
7: ['', '']
8: [unknown_user, '']
8: [unknown_user, known_pass]

scenarios:
-
type: outline
title: scenario1
title: Scenario outline without example
line: 10
steps:
- { keyword_type: 'Given', type: 'Given', text: 'a failing step', line: 11 }
- { keyword_type: 'Given', type: 'Given', text: 'I have browsed to login page', line: 11 }
- { keyword_type: 'When', type: 'When', text: 'I fill in "login" with "<login>"', line: 12 }
- { keyword_type: 'When', type: 'And', text: 'I fill in "password" with "<password>"', line: 13 }
examples:
6: [ login, password ]
7: [ '' , '' ]
8: [ unknown_user , '' ]
8: [ unknown_user , known_pass ]

- type: scenario
title: scenario2
title: A regular scenario
line: 15
steps:
- { keyword_type: 'Given', type: 'Given', text: 'a failing step', line: 16 }
- { keyword_type: 'Given', type: 'Given', text: 'I have browsed to login page', line: 16 }
- { keyword_type: 'When', type: 'When', text: 'I fill in "login" with "user"', line: 17 }
- { keyword_type: 'When', type: 'And', text: 'I fill in "password" with "password"', line: 18 }

- type: outline
title: scenario3
title: Scenario outline with it's own example table
line: 20
steps:
- { keyword_type: 'Given', type: 'Given', text: 'a failing step', line: 21 }
- { keyword_type: 'Given', type: 'Given', text: 'I have browsed to login page', line: 21 }
- { keyword_type: 'When', type: 'When', text: 'I fill in "login" with "<login>"', line: 22 }
- { keyword_type: 'When', type: 'And', text: 'I fill in "password" with "<password>"', line: 23 }
examples:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Feature: Feature with background and example
Feature: Feature with example in the background

Background:
Given a passing step
Examples:
| login | password |
| | |
| unknown_user | |
| login | password |
| | |
| unknown_user | known_pass |

Scenario Outline:
Given a failing step
Scenario Outline: Scenario outline without example table
Given I browse to the login page
When I fill in "login" with "<login>"
And I fill in "password" with "<password>"
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
Feature: Feature with background and example
Feature: Feature with example in background and multiple scenarios

Background:
Given a passing step
Examples:
| login | password |
| | |
| unknown_user | |
| login | password |
| | |
| unknown_user | known_pass |

Scenario Outline: scenario1
Given a failing step
Scenario Outline: Scenario outline without example
Given I have browsed to login page
When I fill in "login" with "<login>"
And I fill in "password" with "<password>"

Scenario: scenario2
Given a failing step
Scenario: A regular scenario
Given I have browsed to login page
When I fill in "login" with "user"
And I fill in "password" with "password"

Scenario Outline: scenario3
Given a failing step
Scenario Outline: Scenario outline with it's own example table
Given I have browsed to login page
When I fill in "login" with "<login>"
And I fill in "password" with "<password>"
Examples:
Expand Down

0 comments on commit 09ffcd4

Please sign in to comment.