Reputation: 2279
I am trying to use an ordered, tagged hook using Java cucumber. For example:
@Before("@quicklink", order = 20)
The compiler doesn't seem to like it. Is it not possible to have an ordered, tagged hook ? Seems like a reasonable combination of functionality. If so, what is the syntax ?
thnx
Upvotes: 6
Views: 5823
Reputation: 174
I have tried the same but in a different way
@Before(value = "@quicklink", order = 20)
But, this may create odd issues if you have another hook method with the same order number for other tests. Like both the methods will run for this scenario.
So I suggest using the tagged expressions if you are using same order like as follows:
For other methods use
@Before(value = "~@quicklink", order = 20)
this will make sure this scenario will never run on other methods
and for this scenario alone,
@Before(value = "@quicklink", order = 20)
this will make sure the above method will never run for those.
If you are using 2x version of tagged expressions in your project, you can replace the '~' with a 'not'
This might come handy if you want to replace a method in hooks class in just a specific scenario.
Upvotes: 3
Reputation: 3026
You should be able to specify the order for hooks like this:
Annotated method style (if you are using cucumber-java):
@Before(order = 10)
public void doSomething(){
// Do something before each scenario
}
Lambda style (if you are using cucumber-java8):
Before(10, () -> {
// Do something before each scenario
});
Upvotes: 0