Package org.moresbycoffee.mbyhave8

Examples of org.moresbycoffee.mbyhave8.Configuration


            hooks.startSpecification(this);
            final Collection<FeatureOutput> featureOutputs = features.stream()
                    .filter(feature -> feature.isExecutable(filter))
                    .map(feature -> featureExecutor.apply(feature, hooks, filter))
                    .collect(Collectors.toList());
            final SpecResult result = ListExtensions.fold(featureOutputs, SpecResult.Success, (previousResult, item) -> previousResult.addFeatureResult(item.getResult()));
            final SpecOutput output = new SpecOutput(testClass.getName(), result, featureOutputs);
            hooks.endSpecification(this, output);
            return output;
        } else {
            return new SpecOutput(testClass.getName(), SpecResult.Success, Collections.emptyList());
View Full Code Here


        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);

        assertEquals(StepResult.Success, result.getResult());
        assertTrue("The and step execution should execute the step implementation and change the visited flag", visited.get());
    }
View Full Code Here

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

        final StepOutput result = andStep.execute(DummyStepHooks.DUMMY);

        assertEquals(StepResult.Success, result.getResult());
        assertTrue("The and step execution should execute the step implementation and change the visited flag", visited.get());
    }
View Full Code Here

    public void implementationLess_and_step_should_return_pending_state() {
        final Step step = new MByHaveSpec() {
            Step innerStep = and("Implementationless Step");
        }.innerStep;

        final StepOutput stepOutput = step.execute(DummyStepHooks.DUMMY);

        assertEquals(StepResult.Pending, stepOutput.getResult());
    }
View Full Code Here

        scenarioOutput.getSteps().forEach(so -> reportStep(so, issues));
    }

    private void reportStep(final StepOutput stepOutput, final Collection<String> issues) {
        final Ansi.Color color;
        final StepResult stepResult = stepOutput.getResult();
        if (stepResult instanceof StepResult.Error) {
            color = RED;
        } else if (stepResult instanceof StepResult.Failure) {
            color = YELLOW;
        } else if (stepResult instanceof StepResult.Pending) {
            color = CYAN;
        } else if (stepResult instanceof StepResult.Skipped) {
            color = MAGENTA;
        } else if (stepResult instanceof StepResult.Success) {
            color = GREEN;
        } else {
            throw new IllegalStateException("The [" + stepResult+ "] step result is not supported by the reporter");
        }

        try {
            final Ansi stepReportOutput = ansi().fg(color).a("        " + stepOutput.getDescription()).reset().newline();
            writer.append(stepReportOutput.toString());
            if (stepResult instanceof StepResult.Error || stepResult instanceof StepResult.Failure) {
                for (final String issue : issues) {
                    final String issueTrackerUrlPattern = Configuration.getConfig("issueTrackerUrlPattern", "%s");
                    writer.append("Issue: " + String.format(issueTrackerUrlPattern, issue) + "\n");
                }
            }

            if (stepResult instanceof StepResult.Error) {
                stepResult.getException().printStackTrace(new PrintWriter(writer, true));
            }
            if (stepResult instanceof StepResult.Failure) {
                stepResult.getException().writeTo(writer, 3);
            }

        } catch (final IOException e) {
            throw new IllegalStateException(e);
        }
View Full Code Here

public class Feature_isExecutableTest {

    @Test
    public void should_be_true_if_there_are_scenarios_in_the_feature() {
        final Feature feature = featureWith(successScenario());
        assertTrue(feature.isExecutable(Filter.EMPTY_FILTER));
    }
View Full Code Here

        assertTrue(feature.isExecutable(Filter.EMPTY_FILTER));
    }

    @Test
    public void empty_feature_should_be_executable() {
        final Feature feature = featureWith();
        assertTrue(feature.isExecutable(Filter.EMPTY_FILTER));
    }
View Full Code Here

        assertTrue(feature.isExecutable(Filter.EMPTY_FILTER));
    }

    @Test
    public void feature_with_only_filtered_out_scenarios_should_not_be_executable() {
        final Feature feature = featureWith(successScenario().tag("Broken"));
        assertFalse(feature.isExecutable(new Filter("~Broken")));
    }
View Full Code Here

    @Test
    public void the_secenario_callbacks_should_be_called_before_and_after_the_scenario() {
        final ScenarioHooks hooks = Mockito.mock(ScenarioHooks.class);
        final InOrder inOrder = Mockito.inOrder(hooks);

        final Scenario scenario = TestUtils.successScenario();

        scenario.execute(hooks);

        final ArgumentCaptor<Scenario> scenarioCaptor = ArgumentCaptor.forClass(Scenario.class);
        inOrder.verify(hooks).startScenario(scenarioCaptor.capture());
        inOrder.verify(hooks).endScenario(Mockito.eq(scenarioCaptor.getValue()), Mockito.eq(ScenarioResult.Success));
View Full Code Here

public class Specification_isExecutableTest {

    @Test
    public void should_be_true_if_there_are_features_in_the_specification() {
        final Specification specification = specificationWith(featureWith(successScenario()));
        assertTrue(specification.isExecuteable(Filter.EMPTY_FILTER));
    }
View Full Code Here

TOP

Related Classes of org.moresbycoffee.mbyhave8.Configuration

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.