-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a8f3a0
commit 73ec18d
Showing
12 changed files
with
124 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
Feature: Hook Parameters | ||
|
||
@spawn | ||
Scenario: before hook parameter | ||
Given a file named "features/my_feature.feature" with: | ||
""" | ||
Feature: a feature | ||
Scenario: a scenario | ||
Given a step | ||
""" | ||
And a file named "features/step_definitions/my_steps.js" with: | ||
""" | ||
import {defineSupportCode} from 'cucumber' | ||
defineSupportCode(({When}) => { | ||
When(/^a step$/, function() {}) | ||
}) | ||
""" | ||
And a file named "features/support/hooks.js" with: | ||
""" | ||
import {defineSupportCode} from 'cucumber' | ||
defineSupportCode(({Before}) => { | ||
Before(function(testCase) { | ||
console.log(testCase.sourceLocation.uri + ":" + testCase.sourceLocation.line) | ||
}) | ||
}) | ||
""" | ||
When I run cucumber.js | ||
Then the output contains the text: | ||
""" | ||
features/my_feature.feature:2 | ||
""" | ||
|
||
@spawn | ||
Scenario: after hook parameter | ||
Given a file named "features/my_feature.feature" with: | ||
""" | ||
Feature: a feature | ||
Scenario: a scenario | ||
Given a passing step | ||
Scenario: another scenario | ||
Given a failing step | ||
""" | ||
And a file named "features/step_definitions/my_steps.js" with: | ||
""" | ||
import {defineSupportCode} from 'cucumber' | ||
defineSupportCode(({When}) => { | ||
When(/^a passing step$/, function() {}) | ||
When(/^a failing step$/, function() { throw new Error("my error") }) | ||
}) | ||
""" | ||
And a file named "features/support/hooks.js" with: | ||
""" | ||
import {defineSupportCode, Status} from 'cucumber' | ||
defineSupportCode(({After}) => { | ||
After(function(testCase) { | ||
let message = testCase.sourceLocation.uri + ":" + testCase.sourceLocation.line + " " | ||
if (testCase.result.status === Status.FAILED) { | ||
message += "failed" | ||
} else { | ||
message += "did not fail" | ||
} | ||
console.log(message) | ||
}) | ||
}) | ||
""" | ||
When I run cucumber.js | ||
Then it fails | ||
And the output contains the text: | ||
""" | ||
features/my_feature.feature:2 did not fail | ||
""" | ||
And the output contains the text: | ||
""" | ||
features/my_feature.feature:5 failed | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.