-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix undefined hook parameter #919
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f24fb83
update
charlierudolph 3ec582a
Merge branch 'master' into cr-testCaseResult
charlierudolph 516dbe9
update
charlierudolph 189806a
update
charlierudolph 62e3cf4
update
charlierudolph 5f3b367
fix
charlierudolph 54dc806
update
charlierudolph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,102 @@ | ||
Feature: Hook Parameters | ||
|
||
Background: | ||
Given a file named "features/my_feature.feature" with: | ||
""" | ||
Feature: a feature | ||
Scenario: a scenario | ||
Given a step | ||
""" | ||
|
||
@spawn | ||
Scenario: before hook parameter | ||
Given a file named "features/step_definitions/my_steps.js" with: | ||
""" | ||
import {defineSupportCode} from 'cucumber' | ||
|
||
defineSupportCode(({When}) => { | ||
When(/^a step$/, function() {}) | ||
}) | ||
""" | ||
Given 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 (failing test case) | ||
Given a file named "features/step_definitions/my_steps.js" with: | ||
""" | ||
import {defineSupportCode} from 'cucumber' | ||
|
||
defineSupportCode(({When}) => { | ||
When(/^a step$/, function() {}) | ||
}) | ||
""" | ||
Given 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 the output contains the text: | ||
""" | ||
features/my_feature.feature:2 did not fail | ||
""" | ||
|
||
@spawn | ||
Scenario: after hook parameter (failing test case) | ||
Given a file named "features/step_definitions/my_steps.js" with: | ||
""" | ||
import {defineSupportCode} from 'cucumber' | ||
|
||
defineSupportCode(({When}) => { | ||
When(/^a step$/, function() { | ||
throw new Error("my error") | ||
}) | ||
}) | ||
""" | ||
Given 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 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need an else? seems like the test case only fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the same After hook as the previous scenario. I'll join the two scenarios into one