parent
75e30ddae9
commit
db0c3da413
@ -0,0 +1,26 @@
|
|||||||
|
package space.kklochko.simple_jbdd.tests.loaders;
|
||||||
|
|
||||||
|
public class SingleClassLoader {
|
||||||
|
String className;
|
||||||
|
|
||||||
|
public SingleClassLoader(String className) {
|
||||||
|
setClassName(className);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<?> load() {
|
||||||
|
try {
|
||||||
|
return Class.forName(getClassName());
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClassName() {
|
||||||
|
return className;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClassName(String className) {
|
||||||
|
this.className = className;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
package space.kklochko.simple_jbdd.tests.loaders
|
||||||
|
|
||||||
|
import space.kklochko.simple_jbdd.test_examples.tests.SimpleThenTest
|
||||||
|
import spock.lang.Narrative
|
||||||
|
import spock.lang.Specification
|
||||||
|
import spock.lang.Subject
|
||||||
|
import spock.lang.Title
|
||||||
|
|
||||||
|
@Narrative("""The loader must return a class or null, so
|
||||||
|
those tests check if responses are right.
|
||||||
|
""")
|
||||||
|
@Title("Integrated tests for ClassLoader.")
|
||||||
|
class IntegratedSingleClassLoader extends Specification {
|
||||||
|
def "The class has been run."() {
|
||||||
|
given: "I have a class loader"
|
||||||
|
@Subject
|
||||||
|
def loader = new SingleClassLoader(className);
|
||||||
|
|
||||||
|
when: "The class was loaded"
|
||||||
|
def aClass = loader.load()
|
||||||
|
|
||||||
|
then: "Checking that the test result is expected"
|
||||||
|
aClass == expectedClass
|
||||||
|
|
||||||
|
where: "Possible variants of tests"
|
||||||
|
className || expectedClass
|
||||||
|
"fourHundredFour" || null
|
||||||
|
"space.kklochko.simple_jbdd.test_examples.tests.SimpleThenTest" || SimpleThenTest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in new issue