Package ar.com.dgarcia.javaspec.impl.model

Examples of ar.com.dgarcia.javaspec.impl.model.SpecGroup


    @Test
    public void shouldContainOneEmptyGroup(){
        SpecTree readSpec = parser.parse(OneEmptyDescribeSpec.class);
        assertThat(readSpec.hasNoTests()).isTrue();

        SpecGroup rootGroup = readSpec.getRootGroup();
        List<SpecGroup> declaredGroups = rootGroup.getSubGroups();
        assertThat(declaredGroups).hasSize(1);

        SpecGroup onlyGroup = declaredGroups.get(0);
        assertThat(onlyGroup.isEmpty()).isTrue();
        assertThat(onlyGroup.getName()).isEqualTo("empty describe");
    }
View Full Code Here


    @Test
    public void theTreeShouldContainOneTestIfOneDefined(){
        SpecTree readSpec = parser.parse(OneRootTestSpecTest.class);
        assertThat(readSpec.hasNoTests()).isFalse();

        SpecGroup rootGroup = readSpec.getRootGroup();
        List<SpecTest> declaredTests = rootGroup.getDeclaredTests();

        assertThat(declaredTests).hasSize(1);

        SpecTest onlyTest = declaredTests.get(0);
        assertThat(onlyTest.getName()).isEqualTo("only test");
View Full Code Here

    @Test
    public void shouldContainOneDescribeWithOneTest(){
        SpecTree readSpec = parser.parse(OneTestInsideDescribeSpecTest.class);

        SpecGroup rootGroup = readSpec.getRootGroup();
        SpecGroup onlyGroup = rootGroup.getSubGroups().get(0);
        assertThat(onlyGroup.getName()).isEqualTo("A suite");

        SpecTest onlyTest = onlyGroup.getDeclaredTests().get(0);
        assertThat(onlyTest.getName()).isEqualTo("contains spec with an expectation");
    }
View Full Code Here

    public void shouldHaveTwoDescribeContexts(){
        SpecTree readSpec = parser.parse(TwoDescribeSpecsTest.class);

        List<SpecGroup> declaredGroups = readSpec.getRootGroup().getSubGroups();

        SpecGroup firstGroup = declaredGroups.get(0);
        assertThat(firstGroup.getName()).isEqualTo("first group");
        assertThat(firstGroup.getDeclaredTests().get(0).getName()).isEqualTo("test in first group");

        SpecGroup secondGroup = declaredGroups.get(1);
        assertThat(secondGroup.getName()).isEqualTo("second group");
        assertThat(secondGroup.getDeclaredTests().get(0).getName()).isEqualTo("test in second group");
    }
View Full Code Here

    @Test
    public void shouldHaveADisabledSuite(){
        SpecTree readSpec = parser.parse(DisabledSuiteSpecTest.class);

        SpecGroup onlyGroup = readSpec.getRootGroup().getSubGroups().get(0);
        assertThat(onlyGroup.getName()).isEqualTo("a disabled spec");
        assertThat(onlyGroup.isMarkedAsDisabled()).isTrue();
    }
View Full Code Here

        assertThat(rootBeforeBlocks).hasSize(1);

        List<Runnable> rootAfterBlocks = onlyRootTest.getAfterBlocks();
        assertThat(rootAfterBlocks).hasSize(1);

        SpecGroup onlyGroup = readSpec.getRootGroup().getSubGroups().get(0);
        SpecTest nestedTest = onlyGroup.getDeclaredTests().get(0);

        List<Runnable> nestedTestBeforeBlocks = nestedTest.getBeforeBlocks();
        assertThat(nestedTestBeforeBlocks).hasSize(2);
        assertThat(nestedTestBeforeBlocks.get(0)).isEqualTo(rootBeforeBlocks.get(0));
View Full Code Here

    @Test
    public void testInsideDisabledSpecShouldBePending(){
        SpecTree readSpec = parser.parse(OneTestInsideDisabledSpecTest.class);

        SpecGroup onlyGroup = readSpec.getRootGroup().getSubGroups().get(0);
        SpecTest disabledTest = onlyGroup.getDeclaredTests().get(0);

        assertThat(disabledTest.isMarkedAsPending()).isTrue();
    }
View Full Code Here

    @Test
    public void variableDefinedInGroupShouldHaveDefinition(){
        SpecTree readSpec = parser.parse(VariableInSuitSpecTest.class);

        SpecGroup onlyGroup = readSpec.getRootGroup().getSubGroups().get(0);

        TestContextDefinition contextDefinition = onlyGroup.getTestContext();
        assertThat(contextDefinition.getDefinitionFor("foo")).isNotNull();
    }
View Full Code Here

    @Test
    public void rootGroupShouldHaveVariableDefinitionAndChildGroupShouldUseParents(){
        SpecTree readSpec = parser.parse(VariableDefinedInParentContextSpecTest.class);

        SpecGroup rootGroup = readSpec.getRootGroup();
        Supplier<Object> rootDefinition = rootGroup.getTestContext().getDefinitionFor("foo");
        assertThat(rootDefinition).isNotNull();

        SpecGroup onlyGroup = rootGroup.getSubGroups().get(0);
        Supplier<Object> childDefinition = onlyGroup.getTestContext().getDefinitionFor("foo");
        assertThat(childDefinition).isSameAs(rootDefinition);
    }
View Full Code Here

     *     The defined tree must be validated before using it
     * @param specTree The tree that will represent this spec
     */
    public void populate(SpecTree specTree) {
        this.specTree = specTree;
        SpecGroup rootGroup = this.specTree.getRootGroup();
        Variable<TestContext> sharedContext = this.specTree.getSharedContext();
        this.stack = SpecStack.create(rootGroup, sharedContext);
        Class<T> expectedContextType = this.getContextTypeFromSubclassDeclaration();
        this.typedContext = TypedContextFactory.createInstanceOf(expectedContextType, sharedContext);
        this.define();
View Full Code Here

TOP

Related Classes of ar.com.dgarcia.javaspec.impl.model.SpecGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.