-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Core] Add Before and AfterStep hooks #1323
Merged
Merged
Changes from 2 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
783828d
Adding AfterStep Feature
89a4c90
add tests for AfterStep
f870014
Adding some more tests and refactoring
442a036
fix JSON formatter and add test to validate afterstep
b98656b
Skipping AfterStep in case step fails or is skipped
5528374
Some code refactoring as per review comments
e0f3980
Updating json formatter to be in sync with ruby implementation for af…
f3c908c
Run after step hook until the next test step from a gherkin step
brasmusson 3ae1cff
Represent AfterHookSteps as substeps of a PickleTestStep
mpkorstanje 1da5039
Extract Step and HookSteps from TestStep
mpkorstanje f926057
Make UNDEFINED less severe then AMBIGUOUS
mpkorstanje 3be655e
Treat before and after hooks like hooks rather then unskipable steps
mpkorstanje 50ef0bf
Hide step implementation details from public api
mpkorstanje 423b961
Hide cucumber.runtime.arguments from the public api
mpkorstanje 75b59bc
Add before step hook
mpkorstanje c7b1cfd
Add lambda before and after step hooks
mpkorstanje 44d4f4f
Use concrete types in runner implementation
mpkorstanje 189aea4
Move getDefinitionArgument down to TestStep
mpkorstanje f6b96da
Update JSONFormatter to include BeforeStep
5fa4360
Add javadoc to steps and events
mpkorstanje 5742014
Add javadoc to TestStep.get*Argument
mpkorstanje a2ffa0f
Nested If..else -> switch
34c11e9
AfterStep should be skipped if BeforeStep fails
c1ef976
Rename TestStep to PickleTestStep, HookStep to TestStep, Step to Test…
mpkorstanje e55c769
Rename TestSteps
mpkorstanje 7e3d10d
Always invoke after step hooks when before step hooks have been invoked
mpkorstanje 4cae4bf
Restore test step methods as deprecated methods
mpkorstanje 5266c0e
Remove unused and unsupported methods from internal api
mpkorstanje 6bce153
Use Step, PickleStep and Hook naming convention
mpkorstanje 26a30d8
Tighten accessibility
mpkorstanje 373f729
Merge branch 'master' of github.com:cucumber/cucumber-jvm into featur…
mpkorstanje e632250
Merge branch 'master' into feature_afterstep
mpkorstanje 92e4fa6
[pom] Update the version of the cucumber-html dependency
brasmusson 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
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,26 @@ | ||
package cucumber.api.java; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.METHOD) | ||
public @interface AfterStep { | ||
/** | ||
* @return a tag expression | ||
*/ | ||
String[] value() default {}; | ||
|
||
/** | ||
* @return max amount of milliseconds this is allowed to run for. 0 (default) means no restriction. | ||
*/ | ||
long timeout() default 0; | ||
|
||
/** | ||
* @return the order in which this hook should run. Higher numbers are run first. | ||
* The default order is 10000. | ||
*/ | ||
int order() default 10000; | ||
} |
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
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
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.
Could you provide a test that shows the after hook is executed after each step?
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.
This also affects the
JSONFormatter
. Currently it assumes all hooks are either before or after hooks. Using after step hooks will have undefined results.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.
@brasmusson where do you think the
TestStepStarted
events for step hooks should go in the json? I am thinking they should go into the same list as the the test steps themselves.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.
@mpkorstanje , I can see afterstep being reported properly in json report. Could you please let me know what exactly is the issue?
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.
I can not. It does indeed all seem to work out.
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.
I will update the class to HookStep instead of Unskipable step and handle the logic of skipping AfterStep for a failed/skipped step. This will be in sync with ruby.
Let me know if that should be ok
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.
I will have to do some changes for JSONFormatter as there is some incosistency when compared with Ruby Json report. Will add a test for same
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.
@mpkorstanje , @brasmusson , I have implemented logic of skipping AfterStep in case of failed or skipped Step and also tests for JSON formatter showing AfterSteps JSON arry node should belong to it's respective step node.
Would you mind reviewing the changes?
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.
I'll look into them, but it will probably take half a week or so before I have the time and energy to do it.
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.
Sure, Thanks