Compare commits

..
3 Commits
Author SHA1 Message Date
KKlochko f384ce5fe5 Add SimpleEmptyTest and its tests.
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2023-10-15 12:37:56 +03:00
KKlochko 5c1e69ed32 Add the error for an empty test.
continuous-integration/drone/tag Build is passing
2023-10-15 12:35:18 +03:00
KKlochko 2e12fdbd34 Update the titles for SimpleFailedThenTest and SimpleGivenWhenThenTest.
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2023-10-15 12:11:56 +03:00
9 changed files with 44 additions and 4 deletions
@@ -0,0 +1,12 @@
package space.kklochko.simple_jbdd.test_examples.tests;
import space.kklochko.simple_jbdd.annotations.Title;
import space.kklochko.simple_jbdd.tests.Test;
@Title("A Simple Empty Test for Sum")
public class SimpleEmptyTest extends Test {
public void check() {
assert 30 == 10 + 20 + 1;
}
}
@@ -5,7 +5,7 @@ import space.kklochko.simple_jbdd.annotations.Title;
import space.kklochko.simple_jbdd.tests.Test; import space.kklochko.simple_jbdd.tests.Test;
@Title("A Simple Failed GivenWhenTest for Sum") @Title("A Simple Failed Then Test for Sum")
public class SimpleFailedThenTest extends Test { public class SimpleFailedThenTest extends Test {
@Then @Then
public void check() { public void check() {
@@ -7,7 +7,7 @@ import space.kklochko.simple_jbdd.annotations.When;
import space.kklochko.simple_jbdd.test_examples.samples.Sum; import space.kklochko.simple_jbdd.test_examples.samples.Sum;
import space.kklochko.simple_jbdd.tests.Test; import space.kklochko.simple_jbdd.tests.Test;
@Title("A Simple GivenWhenTest for Sum") @Title("A Simple GivenWhenThen Test for Sum")
public class SimpleGivenWhenThenTest extends Test { public class SimpleGivenWhenThenTest extends Test {
private Sum sum; private Sum sum;
private int a; private int a;
@@ -0,0 +1,20 @@
package space.kklochko.simple_jbdd.tests.commands.decorators;
import space.kklochko.simple_jbdd.tests.Test;
import space.kklochko.simple_jbdd.tests.commands.AbstractTestCommand;
public class ErrorDecorator<T extends Test> extends AbstractDecorator<T> {
public ErrorDecorator(String error_label, AbstractTestCommand<T> command, String type) {
super(error_label, command);
setType(type);
}
public boolean test() {
return false;
}
public boolean runMethod() {
return false;
};
}
@@ -8,6 +8,7 @@ import space.kklochko.simple_jbdd.tests.Test;
import space.kklochko.simple_jbdd.tests.commands.AbstractTestCommand; import space.kklochko.simple_jbdd.tests.commands.AbstractTestCommand;
import space.kklochko.simple_jbdd.tests.commands.SimpleTestCommand; import space.kklochko.simple_jbdd.tests.commands.SimpleTestCommand;
import space.kklochko.simple_jbdd.tests.commands.decorators.BlockDecorator; import space.kklochko.simple_jbdd.tests.commands.decorators.BlockDecorator;
import space.kklochko.simple_jbdd.tests.commands.decorators.ErrorDecorator;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@@ -20,6 +21,9 @@ public class TestCommandFactory {
AbstractTestCommand<Test> aTestCommand = createTest(aClass, input); AbstractTestCommand<Test> aTestCommand = createTest(aClass, input);
if(test_methods.size() == 0)
return new ErrorDecorator("ERROR!!! No blocks!!!", aTestCommand, "Error");
if(test_methods.containsKey("Then")) { if(test_methods.containsKey("Then")) {
ArrayList<Method> thens = getMethodsInReverseOrder(test_methods, "Then"); ArrayList<Method> thens = getMethodsInReverseOrder(test_methods, "Then");
for(Method then : thens) { for(Method then : thens) {
@@ -1,5 +1,6 @@
package space.kklochko.simple_jbdd.tests.factories package space.kklochko.simple_jbdd.tests.factories
import space.kklochko.simple_jbdd.test_examples.tests.SimpleEmptyTest
import space.kklochko.simple_jbdd.test_examples.tests.SimpleGivenGivenWhenWhenThenThenTest import space.kklochko.simple_jbdd.test_examples.tests.SimpleGivenGivenWhenWhenThenThenTest
import space.kklochko.simple_jbdd.test_examples.tests.SimpleGivenWhenThenTest 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.SimpleThenTest
@@ -33,6 +34,7 @@ class TestCommandFactorySpec extends Specification {
where: where:
testClass || expectedBlockCount testClass || expectedBlockCount
new SimpleEmptyTest() || 0
new SimpleThenTest() || 1 new SimpleThenTest() || 1
new SimpleGivenWhenThenTest() || 3 new SimpleGivenWhenThenTest() || 3
new SimpleGivenGivenWhenWhenThenThenTest() || 6 new SimpleGivenGivenWhenWhenThenThenTest() || 6
@@ -22,7 +22,7 @@ class IntegratedClassLoader extends Specification {
def classes = loader.load() def classes = loader.load()
then: "Checking that the test result is expected" then: "Checking that the test result is expected"
4 == classes.size() 5 == classes.size()
} }
def "The classes must be represent the Test interface."() { def "The classes must be represent the Test interface."() {
@@ -19,7 +19,7 @@ class IntegratedNameClassLoader extends Specification {
def classNames = loader.load() def classNames = loader.load()
then: "Checking that the test result is expected" then: "Checking that the test result is expected"
4 == classNames.size() 5 == classNames.size()
} }
} }
@@ -1,5 +1,6 @@
package space.kklochko.simple_jbdd.tests.runners package space.kklochko.simple_jbdd.tests.runners
import space.kklochko.simple_jbdd.test_examples.tests.SimpleEmptyTest
import space.kklochko.simple_jbdd.test_examples.tests.SimpleFailedThenTest import space.kklochko.simple_jbdd.test_examples.tests.SimpleFailedThenTest
import space.kklochko.simple_jbdd.test_examples.tests.SimpleGivenGivenWhenWhenThenThenTest import space.kklochko.simple_jbdd.test_examples.tests.SimpleGivenGivenWhenWhenThenThenTest
import space.kklochko.simple_jbdd.test_examples.tests.SimpleGivenWhenThenTest import space.kklochko.simple_jbdd.test_examples.tests.SimpleGivenWhenThenTest
@@ -40,5 +41,6 @@ class IntegratedSimpleTestRunnerSpec extends Specification {
new SimpleThenTestWithoutTitle() || true new SimpleThenTestWithoutTitle() || true
new SimpleFailedThenTest() || false new SimpleFailedThenTest() || false
new SimpleGivenGivenWhenWhenThenThenTest() || true new SimpleGivenGivenWhenWhenThenThenTest() || true
new SimpleEmptyTest() || false
} }
} }