Skip to content

Commit

Permalink
error formatting: use pretty format (#866)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlierudolph committed Jun 29, 2017
1 parent 8bf7f17 commit d6805aa
Show file tree
Hide file tree
Showing 24 changed files with 918 additions and 905 deletions.
4 changes: 2 additions & 2 deletions example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ function runFeature() {
},
supportCodeLibrary: supportCodeLibrary
};
var prettyFormatter = Cucumber.FormatterBuilder.build('pretty', formatterOptions);
var progressFormatter = Cucumber.FormatterBuilder.build('progress', formatterOptions);

var runtime = new Cucumber.Runtime({
features: [feature],
listeners: [prettyFormatter],
listeners: [progressFormatter],
supportCodeLibrary: supportCodeLibrary
});
return runtime.start();
Expand Down
11 changes: 5 additions & 6 deletions features/ambiguous_step.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ Feature: Ambiguous Steps
Failures:
1) Scenario: a scenario name - features/a.feature:2
Step: Given a ambiguous step - features/a.feature:3
Message:
Multiple step definitions match:
/^a ambiguous step$/ - features/step_definitions/cucumber_steps.js:4
/^a (.*) step$/ - features/step_definitions/cucumber_steps.js:5
1) Scenario: a scenario name # features/a.feature:2
✖ Given a ambiguous step
Multiple step definitions match:
/^a ambiguous step$/ - features/step_definitions/cucumber_steps.js:4
/^a (.*) step$/ - features/step_definitions/cucumber_steps.js:5
1 scenario (1 ambiguous)
1 step (1 ambiguous)
Expand Down
18 changes: 9 additions & 9 deletions features/custom_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ Feature: custom formatter
Warnings:
1) Scenario: a scenario - features/a.feature:2
Step: Given an undefined step - features/a.feature:3
Message:
Undefined. Implement with the following snippet:
Given('an undefined step', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
1) Scenario: a scenario # features/a.feature:2
? Given an undefined step
Undefined. Implement with the following snippet:
Given('an undefined step', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
1 scenario (1 undefined)
1 step (1 undefined)
Expand Down
12 changes: 1 addition & 11 deletions features/custom_stack_trace.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,4 @@ Feature: Custom stack trace
})
"""
When I run cucumber.js
Then it outputs the text:
"""
Feature: Some feature
Scenario: Some scenario
✔ Given Error.prepareStackTrace has been overriden
1 scenario (1 passed)
1 step (1 passed)
<duration-stat>
"""
Then it passes
115 changes: 115 additions & 0 deletions features/error_formatting.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
Feature: Error formatting
Scenario: failing scenario with hook error
Given a file named "features/a.feature" with:
"""
Feature: some feature
Scenario: some scenario
Given a passing step
"""
And a file named "features/step_definitions/cucumber_steps.js" with:
"""
import {defineSupportCode} from 'cucumber'
defineSupportCode(({Given}) => {
Given(/^a passing step$/, function() {})
})
"""
And a file named "features/support/hooks.js" with:
"""
import {defineSupportCode} from 'cucumber'
defineSupportCode(({Before}) => {
Before(function(_, callback) { callback('Fail') })
})
"""
When I run cucumber.js
Then it fails
And the output contains the text:
"""
Failures:
1) Scenario: some scenario # features/a.feature:2
✖ Before # features/support/hooks.js:4
Error: Fail
"""
And the output contains the text:
"""
- Given a passing step # features/step_definitions/cucumber_steps.js:4
1 scenario (1 failed)
1 step (1 skipped)
<duration-stat>
"""

Scenario: failing scenario has step with doc string
Given a file named "features/a.feature" with:
"""
Feature: some feature
Scenario: some scenario
Given a basic step
And a step with a doc string
\"\"\"
my doc string
\"\"\"
And a pending step
"""
And a file named "features/step_definitions/cucumber_steps.js" with:
"""
import {defineSupportCode} from 'cucumber'
defineSupportCode(({Given}) => {
Given(/^a basic step$/, function() {})
Given(/^a step with a doc string$/, function(str) {})
Given(/^a pending step$/, function() { return 'pending' })
})
"""
When I run cucumber.js
Then the output contains the text:
"""
Warnings:
1) Scenario: some scenario # features/a.feature:3
✔ Given a basic step # features/step_definitions/cucumber_steps.js:4
✔ And a step with a doc string # features/step_definitions/cucumber_steps.js:5
\"\"\"
my doc string
\"\"\"
? And a pending step # features/step_definitions/cucumber_steps.js:6
Pending
"""
And it fails

Scenario: failing scenario has step with data table
Given a file named "features/a.feature" with:
"""
Feature: some feature
Scenario: some scenario
Given a table:
| foo\nbar |bar | baz |
| foo\nbar\n\nbaz\n\\boo |bar | baz\nfoo |
And a pending step
"""
And a file named "features/step_definitions/cucumber_steps.js" with:
"""
import {defineSupportCode} from 'cucumber'
defineSupportCode(({Given}) => {
Given(/^a table:$/, function(table) {})
Given(/^a pending step$/, function() { return 'pending' })
})
"""
When I run cucumber.js
Then the output contains the text:
"""
Warnings:
1) Scenario: some scenario # features/a.feature:3
✔ Given a table: # features/step_definitions/cucumber_steps.js:4
| foo\nbar | bar | baz |
| foo\nbar\n\nbaz\n\\boo | bar | baz\nfoo |
? And a pending step # features/step_definitions/cucumber_steps.js:5
Pending
"""
And it fails
34 changes: 0 additions & 34 deletions features/failed_scenarios.feature

This file was deleted.

9 changes: 2 additions & 7 deletions features/multiple_formatters.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Multiple Formatters
"""

Scenario: Ability to specify multiple formatters
When I run cucumber.js with `-f progress -f pretty:pretty.txt`
When I run cucumber.js with `-f progress -f summary:summary.txt`
Then it outputs the text:
"""
.
Expand All @@ -26,13 +26,8 @@ Feature: Multiple Formatters
1 step (1 passed)
<duration-stat>
"""
And the file "pretty.txt" has the text:
And the file "summary.txt" has the text:
"""
Feature: some feature
Scenario: some scenario
✔ Given a passing step
1 scenario (1 passed)
1 step (1 passed)
<duration-stat>
Expand Down
Loading

0 comments on commit d6805aa

Please sign in to comment.