java - cucumber.runtime.CucumberException:调用 stepDefinition 失败
问题描述
我正在尝试运行用 java 编写的黄瓜测试。
但我不能,因为代码无法调用stepDefinition
:
cucumber.runtime.CucumberException: Failed to invoke stepDefinition.TotalListNumber.a_list_of_real_numbers(Double>) in file:/C:/Users/DELL/eclipse-workspace/TotalListNumber/target/classes/
功能:从实数列表中计算总数
场景:计算实数列表的总和
给定一个实数列表
|25.0|
|1500.0|
|580.0|
|600.0|
当我计算它们的总和时,我会得到 2705.0
。
package stepDefinition;
import org.hamcrest.CoreMatchers;
import com.sun.tools.javac.util.Assert;
import com.sun.tools.javac.util.List;
import static org.junit.Assert.assertThat;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class TotalListNumber {
private double sum;
private List<Double> numbers;
@Given("^a list of real numbers$")
public void a_list_of_real_numbers(List<Double> numbers) throws Throwable {
this.numbers = numbers;
}
@When("^I calculate the sum of them$")
public void I_calculate_the_sum_of_them() throws Throwable {
for (Double number : numbers) {
sum += number;
}
}
@Then("^I will get (\\d+\\.\\d+)$")
public void I_will_get_(Double expectedTotal) throws Throwable {
assertThat(sum, CoreMatchers.is(expectedTotal));
System.out.println("Actual Sum : " + sum);
}
}
package Runner;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"C:\\Users\\DELL\\eclipse-workspace\\TotalListNumber\\src\\main\\java\\Features\\TotalListNumber.feature" },
glue = "stepDefinition",
monochrome = true,
plugin = {"pretty", "html:target/cucumber", "json:target/Cucumber.json", "junit:target/Cucumber.xml"
})
public class TestRunner {
}
解决方案
推荐阅读
- java - Java Spring中用户'root'@'localhost'的访问被拒绝
- python - 如何填充旋转曲线和 2 条水平线之间的区域?
- css - svg 剪辑路径 对角线 翻译
- python - 用于连接 PySide2 中的按钮的 for 循环将所有连接设置为最后一个值
- angular - Angular Material Checkbox 不代表单向绑定值
- javascript - 如何从 jQuery/JavaScript 中提取动态创建的输入字段
- python - 在pyqt5中单击按钮后如何取消单击按钮(重置它)
- sharepoint - 为 Sharepoint 列表创建订阅返回 403 禁止
- python - 有没有办法正确格式化大型 numpy 数组
- java - Time.valueOf 方法返回错误值