Page History
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
package calculator; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import com.xray.tutorials.Calculator; import static org.junit.Assert.*; public class StepDefinitions { private Integer int1; private Integer int2; private Integer result; @Given("I have entered {int} into the calculator") public void i_have_entered_into_the_calculator(Integer int1) { this.int2 = this.int1; this.int1 = int1; } @When("I press add") public void i_press_add() { this.result = Calculator.Add(this.int1, this.int2); } @When("I press multiply") public void i_press_multiply() { this.result = Calculator.Multiply(this.int1, this.int2); } @Then("the result should be {int} on the screen") public void the_result_should_be_on_the_screen(Integer int1value) { // Write code here that turns the phrase above into concrete actions assertEquals((Integer)(this.int1 + this.int2)assertEquals(value, this.result); } } |
- the test runner is defined in the RunCucumberTest class. Cucumber options can be overriden from the command line, whenever executing Maven.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
// Multiply two integers and retuns the result... this code is buggy on purpose public static int Multiply(int num1, int num2 ) { if ((num1==1) ||0) { return num2; } else if (num2==1)0) { return 0num1; } else { return num1 * num2; } } |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
package calculator; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import com.xray.tutorials.Calculator; import static org.junit.Assert.*; public class StepDefinitions { private Integer int1; private Integer int2; private Integer result; @Given("I have entered {int} into the calculator") public void i_have_entered_into_the_calculator(Integer int1) { this.int2 = this.int1; this.int1 = int1; } @When("I press add") public void i_press_add() { this.result = Calculator.Add(this.int1, this.int2); } @When("I press multiply") public void i_press_multiply() { this.result = Calculator.Multiply(this.int1, this.int2); } @Then("the result should be {int} on the screen") public void the_result_should_be_on_the_screen(Integer int1) { // Write code here that turns the phrase above into concrete actionsvalue) { assertEquals((Integer)(this.int1 + this.int2)value, this.result); } } |
- the test runner is defined in the RunCucumberTest class. Cucumber options can be overriden from the command line, whenever executing Maven.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
// Multiply two integers and retuns the result... this code is buggy on purpose public static int Multiply(int num1, int num2 ) { if ((num1==1) ||0) { return num2; } else if (num2==10)) { return 0num1; } else { return num1 * num2; } } |
...