Reputation: 2050
I have one scenario for two different classes.
My Cucumber structure:
Test class:
@RunWith(Cucumber.class)
@CucumberOptions(plugin = "pretty", features = "src\\test\\resources\\samuel\\tripleAnd.feature")//and.feature in first case
public class CucumberTest {
}
Cucumber implementation:
public class ElementsTestSteps implements En {
public ElementsTestSteps() {
Given("^Element test$", () -> {
});
When("^Using element as \"([^\"]*)\"$", (String arg1) -> {
});
//Commented on when using the second scenario
When("^Accept (\\d+) (\\d+)$", (Integer arg1, Integer arg2) -> {
});
//Commented on when using the first scenario
When("^Accept (\\d+) (\\d+)$ (\\d+)$", (Integer arg1, Integer arg2, Integer arg3) -> {
});
Then("^Return (\\d+)$", (Integer arg1) -> {
});
}
}
When I use the follow and.feature
feature all work well:
Scenario Outline:
Given Element test
When Using element as "and"
And Accept <switchA> <switchB>
Then Return <resultSign>
Examples:
| switchA | switchB | resultSign |
| 1 | 1 | 1 |
| 0 | 1 | 0 |
| 1 | 1 | 1 |
...
But when I use the following tripleand.feature
feature I get the The step is undefined
exception:
Scenario Outline:
Given Element test
When Using element as "triple_And"
And Accept <switchA> <switchB> <switchC>
Then Return <resultSign>
Examples:
| switchA | switchB | switchC | resultSign |
| 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
...
Upvotes: 2
Views: 4814
Reputation: 26
You have a simple problem in your below step definition function. You got an extra $ sign after second (\\d+).
When("^Accept (\\\d+) (\\\d+)$ (\\\d+)$", (Integer arg1, Integer arg2, Integer arg3) -> {
});
Upvotes: 1
Reputation: 105
Your second accept regexp is wrong. You have $ symbol appearing twice in that expression. $ means end of line EOL. Remove the first $ and it should work fine. Looks like a simple copy paste error.
Upvotes: 2