Examples of MByHaveSpec


Examples of org.moresbycoffee.mbyhave8.MByHaveSpec

*/
public class ImplementationLessStepTest {

    @Test
    public void implementationless_step_should_make_test_pending() {
        val spec = new MByHaveSpec() {{
            Feature("Implementationless step",
                Scenario("testing implementationless step",
                    given("a step without implementation")));
        }};

        val output = spec.execute();

        assertEquals(SpecResult.Pending, output.getResult());
    }
View Full Code Here

Examples of org.moresbycoffee.mbyhave8.MByHaveSpec

public class SimpleFeatureWithoutRunnerTest {

    @Test
    public void feature_with_one_scenario_and_one_SUCCESS_step_should_be_SUCCESS_format1() {
        val flag = new AtomicBoolean(false);
        val spec = new MByHaveSpec() {
            {
                Feature("this is a feature in the runner",
                    Scenario("this is a scenario",
                        given("something", this::givenStepImplementation)));
            }

            void givenStepImplementation() {
                flag.set(true);
            }
        };

        assertFalse(flag.get());
        val output = spec.execute();
        assertTrue(flag.get());

        assertEquals(SpecResult.Success, output.getResult());
    }
View Full Code Here

Examples of org.moresbycoffee.mbyhave8.MByHaveSpec

    }

    @Test
    public void feature_with_one_scenario_and_one_SUCCESS_step_should_be_SUCCESS_format2() {
        val hasGivenBeenVisited = new AtomicBoolean(false);
        val spec = new MByHaveSpec() {{
            Feature("this is a feature in the runner",
                Scenario("this is a scenario",
                    given("something", () -> { hasGivenBeenVisited.set(true); })));
        }};

        assertFalse(hasGivenBeenVisited.get());
        val output = spec.execute();
        assertTrue(hasGivenBeenVisited.get());
        assertEquals(SpecResult.Success, output.getResult());
    }
View Full Code Here

Examples of org.moresbycoffee.mbyhave8.MByHaveSpec

    }


    @Test
    public void feature_with_one_scenario_and_one_PENDING_step_should_be_PENDING() {
        final MByHaveSpec spec = new MByHaveSpec() {{
            Feature("this is a pending feature",
                Scenario("this is a scenario",
                    given("something", (VoidStepImplementation) () -> { throw new PendingException(); })));
        }};

        final SpecOutput output = spec.execute();

        assertEquals(SpecResult.Pending, output.getResult());
    }
View Full Code Here

Examples of org.moresbycoffee.mbyhave8.MByHaveSpec



    @Test
    public void spec_with_one_SUCCESS_and_one_PENDING_feature_should_be_PENDING() {
        final MByHaveSpec spec = new MByHaveSpec() {{

            Feature("this is a success feature",
                    Scenario("this is a scenario",
                            given("something", () -> { })));


            Feature("this is a pending feature",
                    Scenario("this is a scenario",
                            given("something", (VoidStepImplementation) () -> { throw new PendingException(); })));
        }};

        final SpecOutput output = spec.execute();

        assertEquals(SpecResult.Pending, output.getResult());
    }
View Full Code Here

Examples of org.moresbycoffee.mbyhave8.MByHaveSpec

    public void feature_with_one_FULL_SUCCESS_scenario() {
        final AtomicBoolean givenStepVisitedFlag = new AtomicBoolean(false);
        final AtomicBoolean whenStepVisitedFlag = new AtomicBoolean(false);
        final AtomicBoolean thenStepVisitedFlag = new AtomicBoolean(false);

        final MByHaveSpec spec = new MByHaveSpec() {{

                Feature("this is a feature in the runner",
                    Scenario("this is a scenario",
                        given("something",                         this::givenStepImplementation),
                        when ("something happens",                 this::whenStepImplementation),
                        then ("something should be in some state", this::thenStepImplementation)
                    ));
            }

            void givenStepImplementation() { givenStepVisitedFlag.set(true); }
            void whenStepImplementation()  { whenStepVisitedFlag.set(true); }
            void thenStepImplementation()  { thenStepVisitedFlag.set(true); }
        };

        assertFalse(givenStepVisitedFlag.get() || whenStepVisitedFlag.get() || thenStepVisitedFlag.get());
        final SpecOutput output = spec.execute();
        assertTrue(givenStepVisitedFlag.get() && whenStepVisitedFlag.get() && thenStepVisitedFlag.get());

        assertEquals(SpecResult.Success, output.getResult());
    }
View Full Code Here

Examples of org.moresbycoffee.mbyhave8.MByHaveSpec

    @Test
    public void a_successful_feature_result_should_be_printed_out_in_green() {

        val testOutput = new StringWriter();
        val spec = new MByHaveSpec() {
            {
                Feature("this is a feature without runner",
                    Scenario("this is a scenario",
                        given("something", this::givenStepImplementation)));
            }

            void givenStepImplementation() {
                //Doing nothing
            }
        };

        spec.execute(testOutput);

        assertEquals(ansi().fg(GREEN).a("Feature: this is a feature without runner").reset().newline().
                            fg(GREEN).a("    Scenario: this is a scenario").reset().newline().
                            fg(GREEN).a("        Given something").reset().newline().toString(),
                     testOutput.toString());
View Full Code Here

Examples of org.moresbycoffee.mbyhave8.MByHaveSpec

    public void should_report_issue_if_the_test_fails() {

        try(val ps = setSystemProperties("issueTrackerUrlPattern", "https://bitbucket.org/moresbycoffee/mbyhave8/issue/%s")) {

            val testOutput = new StringWriter();
            val spec = new MByHaveSpec() {{

                Feature("this is a feature without runner",
                    Scenario("this is a scenario",
                        given("something", () -> fail())
                    )
                ).issue("7");

            }};

            spec.execute(testOutput);

            assertThat(testOutput.toString(),
                       startsWith(ansi().fg(YELLOW).a("Feature: this is a feature without runner").reset().newline().
                                         fg(YELLOW).a("    Scenario: this is a scenario").reset().newline().
                                         fg(YELLOW).a("        Given something").reset().newline().
View Full Code Here

Examples of org.moresbycoffee.mbyhave8.MByHaveSpec

    @Test
    public void and_step_execution_should_run_the_step_implementation() {
        final AtomicBoolean visited = new AtomicBoolean(false);

        final Step andStep = new MByHaveSpec() {
            Step innerStep = and("an And step", () -> { visited.set(true); return StepResult.Success; });
        }.innerStep;

        final StepOutput result = andStep.execute(DummyStepHooks.DUMMY);
View Full Code Here

Examples of org.moresbycoffee.mbyhave8.MByHaveSpec

    @Test
    public void and_step_implemenentation_can_be_either_void_return_method() {
        final AtomicBoolean visited = new AtomicBoolean(false);

        final Step andStep = new MByHaveSpec() {
            Step innerStep = and("an And step", () -> visited.set(true));
        }.innerStep;

        final StepOutput result = andStep.execute(DummyStepHooks.DUMMY);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.