Reputation: 1623
I using Java 8 with cucumber. It's possible to create lambda expression for Given, When, Then, And, But e.g.
When("test", (String path) -> this.driver.findElement(By.xpath(path)));
My question is is it possible to create lambda expression form After and Before instead of @Before("@scenarioTest")
or @After("@scenarioTest")
?
Upvotes: 1
Views: 1880
Reputation: 355
If you want to use After/Before without tags you can use
After(()->{
YOUR_CODE;
});
or if you want to pass tags you can do it passing table like this:
String[] tags = {"@tag1", "@tag2"};
Before(tags, ()->YOUR_CODE);
Upvotes: 3