Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1b85e3771 | ||
|
|
0683be643f |
@@ -4,10 +4,10 @@ import space.kklochko.simple_jbdd.tests.Test;
|
|||||||
import space.kklochko.simple_jbdd.tests.commands.AbstractTestCommand;
|
import space.kklochko.simple_jbdd.tests.commands.AbstractTestCommand;
|
||||||
|
|
||||||
public class SimpleTestRunner extends AbstractTestRunner {
|
public class SimpleTestRunner extends AbstractTestRunner {
|
||||||
AbstractTestCommand<Test> command;
|
private AbstractTestCommand<Test> command;
|
||||||
|
|
||||||
public SimpleTestRunner(AbstractTestCommand<Test> command) {
|
public SimpleTestRunner(AbstractTestCommand<Test> command) {
|
||||||
this.command = command;
|
setCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean run() {
|
public boolean run() {
|
||||||
|
|||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
package space.kklochko.simple_jbdd.tests.runners
|
||||||
|
|
||||||
|
import space.kklochko.simple_jbdd.test_examples.tests.SimpleFailedThenTest
|
||||||
|
import space.kklochko.simple_jbdd.test_examples.tests.SimpleGivenWhenThenTest
|
||||||
|
import space.kklochko.simple_jbdd.test_examples.tests.SimpleThenTest
|
||||||
|
import space.kklochko.simple_jbdd.test_examples.tests.SimpleThenTestWithoutTitle
|
||||||
|
import space.kklochko.simple_jbdd.tests.factories.TestCommandFactory
|
||||||
|
import spock.lang.Narrative
|
||||||
|
import spock.lang.Specification
|
||||||
|
import spock.lang.Subject
|
||||||
|
import spock.lang.Title
|
||||||
|
|
||||||
|
@Narrative("""The runner must return a result of test, so
|
||||||
|
those tests check if passed and failed test generate the right result.
|
||||||
|
""")
|
||||||
|
@Title("Integrated tests for SimpleTestRunner with TestCommandFactory and test examples")
|
||||||
|
class IntegratedSimpleTestRunnerSpec extends Specification {
|
||||||
|
def "The real test has been run."() {
|
||||||
|
given: "I have a factory"
|
||||||
|
def factory = new TestCommandFactory();
|
||||||
|
|
||||||
|
and: "I have a testCommand created from a test object"
|
||||||
|
def test = factory.create(testObject)
|
||||||
|
|
||||||
|
and: "I have a test runner"
|
||||||
|
@Subject
|
||||||
|
def runner = new SimpleTestRunner(test)
|
||||||
|
|
||||||
|
when: "The testCommand has been run"
|
||||||
|
def result = runner.run()
|
||||||
|
|
||||||
|
then: "Checking that the test result is expected"
|
||||||
|
result == expectedResult
|
||||||
|
|
||||||
|
where: "Possible variants of tests"
|
||||||
|
testObject || expectedResult
|
||||||
|
new SimpleThenTest() || true
|
||||||
|
new SimpleGivenWhenThenTest() || true
|
||||||
|
new SimpleThenTestWithoutTitle() || true
|
||||||
|
new SimpleFailedThenTest() || false
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-41
@@ -1,7 +1,5 @@
|
|||||||
package space.kklochko.simple_jbdd.tests.runners
|
package space.kklochko.simple_jbdd.tests.runners
|
||||||
|
|
||||||
import space.kklochko.simple_jbdd.test_examples.tests.SimpleFailedThenTest
|
|
||||||
import space.kklochko.simple_jbdd.test_examples.tests.SimpleThenTest
|
|
||||||
import space.kklochko.simple_jbdd.tests.commands.SimpleTestCommand
|
import space.kklochko.simple_jbdd.tests.commands.SimpleTestCommand
|
||||||
import space.kklochko.simple_jbdd.tests.factories.TestCommandFactory
|
import space.kklochko.simple_jbdd.tests.factories.TestCommandFactory
|
||||||
import spock.lang.Narrative
|
import spock.lang.Narrative
|
||||||
@@ -30,25 +28,6 @@ class SimpleTestRunnerSpec extends Specification {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
def "The real test with then has been passed."() {
|
|
||||||
given: "I have a test and a factory"
|
|
||||||
def aTest = new SimpleThenTest()
|
|
||||||
def factory = new TestCommandFactory();
|
|
||||||
|
|
||||||
and: "I have a testCommand"
|
|
||||||
def test = factory.create(aTest)
|
|
||||||
|
|
||||||
and: "I have a test runner"
|
|
||||||
@Subject
|
|
||||||
def runner = new SimpleTestRunner(test)
|
|
||||||
|
|
||||||
when: "The testCommand has been run"
|
|
||||||
def result = runner.run()
|
|
||||||
|
|
||||||
then: "The result is true"
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
def "The test with then that has not been passed."() {
|
def "The test with then that has not been passed."() {
|
||||||
given: "I have a failed testCommand"
|
given: "I have a failed testCommand"
|
||||||
def test = Stub(SimpleTestCommand)
|
def test = Stub(SimpleTestCommand)
|
||||||
@@ -61,26 +40,7 @@ class SimpleTestRunnerSpec extends Specification {
|
|||||||
when: "The testCommand has been run"
|
when: "The testCommand has been run"
|
||||||
def result = runner.run()
|
def result = runner.run()
|
||||||
|
|
||||||
then: "The result is true"
|
then: "The result is false"
|
||||||
!result
|
|
||||||
}
|
|
||||||
|
|
||||||
def "The real test with then has not been passed."() {
|
|
||||||
given: "I have a test and a factory"
|
|
||||||
def aTest = new SimpleFailedThenTest()
|
|
||||||
def factory = new TestCommandFactory();
|
|
||||||
|
|
||||||
and: "I have a testCommand"
|
|
||||||
def test = factory.create(aTest)
|
|
||||||
|
|
||||||
and: "I have a test runner"
|
|
||||||
@Subject
|
|
||||||
def runner = new SimpleTestRunner(test)
|
|
||||||
|
|
||||||
when: "The testCommand has been run"
|
|
||||||
def result = runner.run()
|
|
||||||
|
|
||||||
then: "The result is true"
|
|
||||||
!result
|
!result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user