我已经编写了一个代码来测试将项目添加到库存中,但我不断收到 Arity 不匹配错误。
我的代码如下:
@When("^(Coffee|Milk|Sugar|Chocolate) is (.*)$")
@Then("^Inventory is successfully added\\.$")
public void inventory_is_successfully_added(String Coffee, String milk, String sugar, String chocolate) throws InventoryException {
coffeeMaker.addInventory(Coffee,milk,sugar,chocolate);
System.out.println("Inventory is successfully added.");
}
并且在功能文件中编写的相应场景是这样的:
Scenario: Add Inventory
When Coffee is 4
When Milk is 7
When Sugar is 0
When Chocolate is 9
Then Inventory is successfully added.
这是我得到的错误:
cucumber.runtime.CucumberException: Arity mismatch: Step Definition 'edu.ncsu.csc326.coffeemaker.TestSteps.inventory_is_successfully_added(String,String,String,String) in file:/D:/newEclipse/Assign/build/classes/java/test/' with pattern [^(Coffee|Milk|Sugar|Chocolate) is (.*)$] is declared with 4 parameters. However, the gherkin step has 2 arguments [Coffee, 4].
有人可以告诉我这是什么意思吗?TIA