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

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


        assertThat(onlyGroup.isMarkedAsDisabled()).isTrue();
    }

    @Test
    public void testShouldHaveABeforeCode(){
        SpecTree readSpec = parser.parse(BeforeUsedInOneTestSpecTest.class);

        SpecTest onlyTest = readSpec.getRootGroup().getDeclaredTests().get(0);
        assertThat(onlyTest.getName()).isEqualTo("test with before");

        List<Runnable> testBeforeBlocks = onlyTest.getBeforeBlocks();
        assertThat(testBeforeBlocks).hasSize(1);
    }
View Full Code Here


        assertThat(testBeforeBlocks).hasSize(1);
    }

    @Test
    public void testShouldHaveAnAfterCode(){
        SpecTree readSpec = parser.parse(AfterUsedInOneTestSpecTest.class);

        SpecTest onlyTest = readSpec.getRootGroup().getDeclaredTests().get(0);
        assertThat(onlyTest.getName()).isEqualTo("test with after");

        List<Runnable> testAfterBlocks = onlyTest.getAfterBlocks();
        assertThat(testAfterBlocks).hasSize(1);
    }
View Full Code Here

        assertThat(testAfterBlocks).hasSize(1);
    }

    @Test
    public void testShouldHave2BeforeAnd2AfterCodes(){
        SpecTree readSpec = parser.parse(TwoBeforeAndAfterTestSpecTest.class);

        SpecTest onlyTest = readSpec.getRootGroup().getDeclaredTests().get(0);
        assertThat(onlyTest.getName()).isEqualTo("test with 2 before and 2 after");

        List<Runnable> testBeforeBlocks = onlyTest.getBeforeBlocks();
        assertThat(testBeforeBlocks).hasSize(2);
View Full Code Here

        assertThat(testAfterBlocks).hasSize(2);
    }

    @Test
    public void shouldHave1RootTestWith1BeforeAfterAnd1NestedTestWith2BeforeAnd2AfterCodes(){
        SpecTree readSpec = parser.parse(BeforeAndAfterInheritedWhenNestedTest.class);

        SpecTest onlyRootTest = readSpec.getRootGroup().getDeclaredTests().get(0);
        assertThat(onlyRootTest.getName()).isEqualTo("test with 1 before/after set");

        List<Runnable> rootBeforeBlocks = onlyRootTest.getBeforeBlocks();
        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

        assertThat(disabledTest.isMarkedAsPending()).isTrue();
    }

    @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

        assertThat(contextDefinition.getDefinitionFor("foo")).isNotNull();
    }

    @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");
View Full Code Here

    /**
     * Creates the test tree to be used to describe and execute the tests in junit
     */
    private void createJunitTestTreeFromSpecClass() throws InitializationError {
        SpecTree specTree = SpecParser.create().parse(clase);
        if(specTree.hasNoTests()){
            throw new InitializationError("The spec class["+clase.getSimpleName()+"] has no tests. You must at least use one it() or one xit() inside your definition method");
        }
        junitAdapter = JunitTestTreeAdapter.create(specTree, clase);
    }
View Full Code Here

        parser = SpecParser.create();
    }

    @Test
    public void itShouldParseAnEmptyTreeIfNoSpecDefined(){
        SpecTree readSpec = parser.parse(EmptySpec.class);
        assertThat(readSpec.hasNoTests()).isTrue();
    }
View Full Code Here

        assertThat(readSpec.hasNoTests()).isTrue();
    }

    @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();
View Full Code Here

TOP

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

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.