parent
8b7ba5f18b
commit
e6de1bde03
@ -0,0 +1,16 @@
|
|||||||
|
package space.kklochko.simple_jbdd.test_examples.samples;
|
||||||
|
|
||||||
|
public class Calculator {
|
||||||
|
public int plus(int a, int b) {
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int subtract(int a, int b) {
|
||||||
|
return a - b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int multiply(int a, int b) {
|
||||||
|
return a * b + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
|||||||
|
package space.kklochko.simple_jbdd.test_examples.tests;
|
||||||
|
|
||||||
|
import space.kklochko.simple_jbdd.annotations.Given;
|
||||||
|
import space.kklochko.simple_jbdd.annotations.Then;
|
||||||
|
import space.kklochko.simple_jbdd.annotations.Title;
|
||||||
|
import space.kklochko.simple_jbdd.annotations.When;
|
||||||
|
import space.kklochko.simple_jbdd.test_examples.samples.Calculator;
|
||||||
|
import space.kklochko.simple_jbdd.tests.Test;
|
||||||
|
|
||||||
|
@Title("3*3 must be 9")
|
||||||
|
public class CalculatorMultiplyTest extends Test {
|
||||||
|
Calculator calculator;
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
@Given("Set up the calculator")
|
||||||
|
public void given() {
|
||||||
|
calculator = new Calculator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Given("Set up the arguments")
|
||||||
|
public void setupArguments() {
|
||||||
|
a = 3;
|
||||||
|
b = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@When("Invoke the multiply method")
|
||||||
|
public void when() {
|
||||||
|
result = calculator.multiply(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Then("3*3 must be 9")
|
||||||
|
public void then() {
|
||||||
|
assert result == 9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
|||||||
|
package space.kklochko.simple_jbdd.test_examples.tests;
|
||||||
|
|
||||||
|
import space.kklochko.simple_jbdd.annotations.Given;
|
||||||
|
import space.kklochko.simple_jbdd.annotations.Then;
|
||||||
|
import space.kklochko.simple_jbdd.annotations.Title;
|
||||||
|
import space.kklochko.simple_jbdd.annotations.When;
|
||||||
|
import space.kklochko.simple_jbdd.test_examples.samples.Calculator;
|
||||||
|
import space.kklochko.simple_jbdd.tests.Test;
|
||||||
|
|
||||||
|
@Title("2+2 must be 4")
|
||||||
|
public class CalculatorPlusTest extends Test {
|
||||||
|
Calculator calculator;
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
@Given("Set up the calculator")
|
||||||
|
public void given() {
|
||||||
|
calculator = new Calculator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Given("Set up the arguments")
|
||||||
|
public void setupArguments() {
|
||||||
|
a = b = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@When("Invoke the plus method")
|
||||||
|
public void when() {
|
||||||
|
result = calculator.plus(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Then("2+2 must be 4")
|
||||||
|
public void then() {
|
||||||
|
assert result == 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
|||||||
|
package space.kklochko.simple_jbdd.test_examples.tests;
|
||||||
|
|
||||||
|
import space.kklochko.simple_jbdd.annotations.Given;
|
||||||
|
import space.kklochko.simple_jbdd.annotations.Then;
|
||||||
|
import space.kklochko.simple_jbdd.annotations.Title;
|
||||||
|
import space.kklochko.simple_jbdd.annotations.When;
|
||||||
|
import space.kklochko.simple_jbdd.test_examples.samples.Calculator;
|
||||||
|
import space.kklochko.simple_jbdd.tests.Test;
|
||||||
|
|
||||||
|
@Title("4-2 must be 2")
|
||||||
|
public class CalculatorSubtractTes extends Test {
|
||||||
|
Calculator calculator;
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
@Given("Set up the calculator")
|
||||||
|
public void given() {
|
||||||
|
calculator = new Calculator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Given("Set up the arguments")
|
||||||
|
public void setupArguments() {
|
||||||
|
a = 4;
|
||||||
|
b = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@When("Invoke the subtract method")
|
||||||
|
public void when() {
|
||||||
|
result = calculator.subtract(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Then("4-2 must be 2")
|
||||||
|
public void then() {
|
||||||
|
assert result == 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
|||||||
|
package space.kklochko.simple_jbdd.test_examples.tests;
|
||||||
|
|
||||||
|
import space.kklochko.simple_jbdd.annotations.Given;
|
||||||
|
import space.kklochko.simple_jbdd.annotations.Then;
|
||||||
|
import space.kklochko.simple_jbdd.annotations.Title;
|
||||||
|
import space.kklochko.simple_jbdd.annotations.When;
|
||||||
|
import space.kklochko.simple_jbdd.test_examples.samples.Calculator;
|
||||||
|
import space.kklochko.simple_jbdd.tests.Test;
|
||||||
|
|
||||||
|
@Title("4-2 must be 2")
|
||||||
|
public class CalculatorSubtractTest extends Test {
|
||||||
|
Calculator calculator;
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
@Given("Set up the calculator")
|
||||||
|
public void given() {
|
||||||
|
calculator = new Calculator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Given("Set up the arguments")
|
||||||
|
public void setupArguments() {
|
||||||
|
a = 4;
|
||||||
|
b = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@When("Invoke the subtract method")
|
||||||
|
public void when() {
|
||||||
|
result = calculator.subtract(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Then("4-2 must be 2")
|
||||||
|
public void then() {
|
||||||
|
assert result == 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in new issue