Refactor tests for the SimpleTestRunner.
continuous-integration/drone/push Build is passing Details

main
KKlochko 2 years ago
parent e67bdc4bb0
commit 0683be643f

@ -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,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
}
}

Loading…
Cancel
Save