cucumber.runtime.junit.UndefinedThrowable: 步骤未定义
cucumber.runtime.junit.UndefinedThrowable: The step is undefined
我有两种不同的 classes 的一种情况。
我的 Cucumber 结构:
测试class:
@RunWith(Cucumber.class)
@CucumberOptions(plugin = "pretty", features = "src\test\resources\samuel\tripleAnd.feature")//and.feature in first case
public class CucumberTest {
}
黄瓜实现:
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) -> {
});
}
}
当我使用以下 and.feature
功能时一切正常:
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 |
...
但是当我使用以下 tripleand.feature
功能时,我得到 The step is undefined
异常:
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 |
...
为什么第一种情况一切顺利,而第二种情况却不顺利?
你的第二个接受正则表达式是错误的。你有 $ 符号在该表达式中出现两次。 $ 表示行尾 EOL。删除第一个 $ ,它应该可以正常工作。看起来像一个简单的复制粘贴错误。
您在下面的步骤定义函数中遇到了一个简单的问题。在第二个 (\\d+).
之后你得到了一个额外的 $ 符号
When("^Accept (\\d+) (\\d+)$ (\\d+)$", (Integer arg1, Integer arg2, Integer arg3) -> {
});
我有两种不同的 classes 的一种情况。
我的 Cucumber 结构:
测试class:
@RunWith(Cucumber.class) @CucumberOptions(plugin = "pretty", features = "src\test\resources\samuel\tripleAnd.feature")//and.feature in first case public class CucumberTest { }
黄瓜实现:
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) -> { }); } }
当我使用以下
and.feature
功能时一切正常: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 | ...
但是当我使用以下
tripleand.feature
功能时,我得到The step is undefined
异常: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 | ...
为什么第一种情况一切顺利,而第二种情况却不顺利?
你的第二个接受正则表达式是错误的。你有 $ 符号在该表达式中出现两次。 $ 表示行尾 EOL。删除第一个 $ ,它应该可以正常工作。看起来像一个简单的复制粘贴错误。
您在下面的步骤定义函数中遇到了一个简单的问题。在第二个 (\\d+).
之后你得到了一个额外的 $ 符号When("^Accept (\\d+) (\\d+)$ (\\d+)$", (Integer arg1, Integer arg2, Integer arg3) -> {
});