I have written a code to test adding items into an inventory but i keep getting Arity mismatch error.
My code is as follows:
@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.");
}
and the corresponding Scenario written in feature file is this:
Scenario: Add Inventory
When Coffee is 4
When Milk is 7
When Sugar is 0
When Chocolate is 9
Then Inventory is successfully added.
This is the error I get:
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].
can someone please tell me what it means? TIA