diff --git a/src/test/groovy/space/kklochko/simple_jbdd/tests/runners/IntegratedSimpleTestRunnerSpec.groovy b/src/test/groovy/space/kklochko/simple_jbdd/tests/runners/IntegratedSimpleTestRunnerSpec.groovy new file mode 100644 index 0000000..4fa2794 --- /dev/null +++ b/src/test/groovy/space/kklochko/simple_jbdd/tests/runners/IntegratedSimpleTestRunnerSpec.groovy @@ -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 + } +} diff --git a/src/test/groovy/space/kklochko/simple_jbdd/tests/runners/SimpleTestRunnerSpec.groovy b/src/test/groovy/space/kklochko/simple_jbdd/tests/runners/SimpleTestRunnerSpec.groovy index 3edcee2..5f0b7bb 100644 --- a/src/test/groovy/space/kklochko/simple_jbdd/tests/runners/SimpleTestRunnerSpec.groovy +++ b/src/test/groovy/space/kklochko/simple_jbdd/tests/runners/SimpleTestRunnerSpec.groovy @@ -1,7 +1,5 @@ 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.factories.TestCommandFactory import spock.lang.Narrative @@ -30,25 +28,6 @@ class SimpleTestRunnerSpec extends Specification { 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."() { given: "I have a failed testCommand" def test = Stub(SimpleTestCommand) @@ -64,24 +43,5 @@ class SimpleTestRunnerSpec extends Specification { then: "The result is true" !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 - } }