Merge cucumber -> testing
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.baeldung.testing.calculator;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import cucumber.api.CucumberOptions;
|
||||
import cucumber.api.junit.Cucumber;
|
||||
|
||||
@RunWith(Cucumber.class)
|
||||
@CucumberOptions(
|
||||
features={"classpath:features/calculator.feature", "classpath:features/calculator-scenario-outline.feature"}
|
||||
, plugin = { "pretty", "json:target/reports/json/calculator.json" }
|
||||
, glue = {"com.baeldung.cucumber.calculator"}
|
||||
)
|
||||
public class CalculatorIntegrationTest {
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.baeldung.testing.calculator;
|
||||
|
||||
import com.baeldung.cucumber.Calculator;
|
||||
import cucumber.api.java.Before;
|
||||
import cucumber.api.java.en.Given;
|
||||
import cucumber.api.java.en.Then;
|
||||
import cucumber.api.java.en.When;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
|
||||
public class CalculatorRunSteps {
|
||||
|
||||
private int total;
|
||||
|
||||
private Calculator calculator;
|
||||
|
||||
@Before
|
||||
private void init() {
|
||||
total = -999;
|
||||
|
||||
}
|
||||
|
||||
@Given("^I have a calculator$")
|
||||
public void initializeCalculator() throws Throwable {
|
||||
calculator = new Calculator();
|
||||
}
|
||||
|
||||
@When("^I add (-?\\d+) and (-?\\d+)$")
|
||||
public void testAdd(int num1, int num2) throws Throwable {
|
||||
total = calculator.add(num1, num2);
|
||||
}
|
||||
|
||||
@Then("^the result should be (-?\\d+)$")
|
||||
public void validateResult(int result) throws Throwable {
|
||||
Assert.assertThat(total, Matchers.equalTo(result));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user