【发布时间】:2020-05-23 18:24:43
【问题描述】:
我正在学习 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
对于上述场景 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();
}
如果我尝试输入为
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
那么 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();
}
我也尝试在引号内提供数组
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
但是 cucumber 期望 String 作为输入
@Given("The nonnull integer array {string}")
public void the_nonnull_integer_array(String string) {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
我尝试了各种其他方法,但均未成功。任何人都可以提出更好的方法来处理这种测试场景吗?
【问题讨论】:
标签: unit-testing junit cucumber cucumber-java cucumber-junit