簡體   English   中英

cucumber.runtime.junit.UndefinedThrowable:步驟未定義

[英]cucumber.runtime.junit.UndefinedThrowable: The step is undefined

我有兩個不同課程的一個場景。

我的 Cucumber 結構:

  • 測試 class:

     @RunWith(Cucumber.class) @CucumberOptions(plugin = "pretty", features = "src\\test\\resources\\samuel\\tripleAnd.feature")//and.feature in first case public class CucumberTest { }
  • Cucumber 實現:

     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) -> { }); } }
  • 當我使用 follow 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。 刪除第一個 $ ,它應該可以正常工作。 看起來像一個簡單的復制粘貼錯誤。

您在下面的步驟定義 function 中有一個簡單的問題。 在第二個(\\d+)之后你有一個額外的$符號。

When("^Accept (\\\d+) (\\\d+)$ (\\\d+)$", (Integer arg1, Integer arg2, Integer arg3) -> {
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM