简体   繁体   中英

cucumber.runtime.junit.UndefinedThrowable: The step is undefined

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 |...

Why is everything going well in the first case but not the second?

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.

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) -> {
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM