now builds test descriptions recursively
This commit is contained in:
parent
45d32509ef
commit
695f0101c0
|
@ -0,0 +1,50 @@
|
||||||
|
package be.klak.junit.jasmine;
|
||||||
|
|
||||||
|
import static org.fest.assertions.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.Description;
|
||||||
|
|
||||||
|
public class DescriptionsRecursiveTreeInRunnerTest {
|
||||||
|
|
||||||
|
@JasmineSuite(specs = { "recursiveSpec.js" })
|
||||||
|
private class RecursiveTreeTest {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void buildDescriptionsRecursively() {
|
||||||
|
Description baseTestDescription = new JasmineTestRunner(RecursiveTreeTest.class).getDescription();
|
||||||
|
assertThat(baseTestDescription.getDisplayName()).contains(RecursiveTreeTest.class.getSimpleName());
|
||||||
|
|
||||||
|
assertThat(baseTestDescription.getChildren()).hasSize(1);
|
||||||
|
Description root = baseTestDescription.getChildren().get(0);
|
||||||
|
assertThat(root.getDisplayName()).isEqualTo("root");
|
||||||
|
assertThat(root.getChildren()).hasSize(3);
|
||||||
|
|
||||||
|
assertThat(root.getChildren().get(0).getDisplayName()).isEqualTo("rootTest");
|
||||||
|
assertChild1AndChildren(root);
|
||||||
|
assertChild2AndChildren(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertChild2AndChildren(Description root) {
|
||||||
|
Description child2 = root.getChildren().get(2);
|
||||||
|
assertThat(child2.getDisplayName()).isEqualTo("child2");
|
||||||
|
|
||||||
|
assertThat(child2.getChildren()).hasSize(1);
|
||||||
|
assertThat(child2.getChildren().get(0).getDisplayName()).isEqualTo("child2Test");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertChild1AndChildren(Description root) {
|
||||||
|
Description child1 = root.getChildren().get(1);
|
||||||
|
assertThat(child1.getDisplayName()).isEqualTo("child1");
|
||||||
|
|
||||||
|
assertThat(child1.getChildren()).hasSize(2);
|
||||||
|
assertThat(child1.getChildren().get(0).getDisplayName()).isEqualTo("child1Test");
|
||||||
|
Description grandchild = child1.getChildren().get(1);
|
||||||
|
assertThat(grandchild.getDisplayName()).isEqualTo("grandchild");
|
||||||
|
|
||||||
|
assertThat(grandchild.getChildren()).hasSize(1);
|
||||||
|
assertThat(grandchild.getChildren().get(0).getDisplayName()).isEqualTo("grandchildTest");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package be.klak.junit.jasmine;
|
||||||
|
|
||||||
|
import static org.fest.assertions.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.Description;
|
||||||
|
|
||||||
|
import be.klak.junit.jasmine.classes.JasmineSuiteGeneratorClassWithRunner;
|
||||||
|
|
||||||
|
public class DescriptionsWithMultipleSpecFilesTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDescriptionsShouldIncludeBothSpec1AndSpec2SuiteInfo() {
|
||||||
|
Description root = new JasmineTestRunner(JasmineSuiteGeneratorClassWithRunner.class).getDescription();
|
||||||
|
|
||||||
|
assertThat(root.getChildren()).hasSize(2);
|
||||||
|
Description spec1 = root.getChildren().get(0);
|
||||||
|
assertThat(spec1.getDisplayName()).isEqualTo("spec 1");
|
||||||
|
assertThat(spec1.getChildren()).hasSize(1);
|
||||||
|
|
||||||
|
Description spec2 = root.getChildren().get(1);
|
||||||
|
assertThat(spec2.getDisplayName()).isEqualTo("spec 2");
|
||||||
|
assertThat(spec2.getChildren()).hasSize(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
describe("root", function() {
|
||||||
|
|
||||||
|
it("rootTest", function() {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("child1", function() {
|
||||||
|
|
||||||
|
it("child1Test", function() {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("grandchild", function() {
|
||||||
|
|
||||||
|
it("grandchildTest", function() {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("child2", function() {
|
||||||
|
|
||||||
|
it("child2Test", function() {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Reference in New Issue