小编Dar*_*hia的帖子

在编写单元测试用例时,如何将整数数组从 Cucumber 功能文件传递到步骤定义

我正在学习 Cucumber 进行单元测试,并尝试为 Radix Sort 代码编写单元测试。但我无法弄清楚如何提供整数数组作为特征文件中基数排序代码的输入。

我尝试提供以下输入:

  Scenario: Sorting integer array using radix sort within the specified range
    Given The nonnull integer array 10,25,0,1
    When radix sort is performed over the range from 0 to 7
    Then validate if the array is sorted

Run Code Online (Sandbox Code Playgroud)

对于上述场景,cucumber 需要下面提到的代码体:

@Given("The nonnull integer array {double}")
public void the_nonnull_integer_array(Double double1) {
    // Write code here that turns the phrase above into concrete actions
    throw new io.cucumber.java.PendingException();
}
Run Code Online (Sandbox Code Playgroud)

如果我尝试输入为

    Scenario: Sorting integer array using radix sort within …
Run Code Online (Sandbox Code Playgroud)

junit unit-testing cucumber cucumber-junit cucumber-java

9
推荐指数
1
解决办法
2万
查看次数