Search in sources :

Example 26 with Step

use of gherkin.formatter.model.Step in project cucumber-jvm by cucumber.

the class RuntimeTest method strict_with_undefined_steps.

@Test
public void strict_with_undefined_steps() {
    Runtime runtime = createStrictRuntime();
    runtime.undefinedStepsTracker.addUndefinedStep(new Step(null, "Given ", "A", 1, null, null), ENGLISH);
    assertEquals(0x1, runtime.exitStatus());
}
Also used : Step(gherkin.formatter.model.Step) Test(org.junit.Test)

Example 27 with Step

use of gherkin.formatter.model.Step in project cucumber-jvm by cucumber.

the class Runtime method runUnreportedStep.

//TODO: Maybe this should go into the cucumber step execution model and it should return the result of that execution!
@Override
public void runUnreportedStep(String featurePath, I18n i18n, String stepKeyword, String stepName, int line, List<DataTableRow> dataTableRows, DocString docString) throws Throwable {
    Step step = new Step(Collections.<Comment>emptyList(), stepKeyword, stepName, line, dataTableRows, docString);
    StepDefinitionMatch match = glue.stepDefinitionMatch(featurePath, step, i18n);
    if (match == null) {
        UndefinedStepException error = new UndefinedStepException(step);
        StackTraceElement[] originalTrace = error.getStackTrace();
        StackTraceElement[] newTrace = new StackTraceElement[originalTrace.length + 1];
        newTrace[0] = new StackTraceElement("✽", "StepDefinition", featurePath, line);
        System.arraycopy(originalTrace, 0, newTrace, 1, originalTrace.length);
        error.setStackTrace(newTrace);
        throw error;
    }
    match.runStep(i18n);
}
Also used : Step(gherkin.formatter.model.Step)

Example 28 with Step

use of gherkin.formatter.model.Step in project cucumber-jvm by cucumber.

the class JUnitReporterTest method mockStep.

private Step mockStep(String stepName) {
    Step step = mock(Step.class);
    when(step.getName()).thenReturn(stepName);
    return step;
}
Also used : Step(gherkin.formatter.model.Step)

Example 29 with Step

use of gherkin.formatter.model.Step in project cucumber-jvm by cucumber.

the class JUnitReporterTest method match_allow_stared_ignored.

@Test
public void match_allow_stared_ignored() {
    createAllowStartedIgnoredReporter();
    Step runnerStep = mockStep();
    Description runnerStepDescription = stepDescription(runnerStep);
    ExecutionUnitRunner executionUnitRunner = mockExecutionUnitRunner(runnerSteps(runnerStep));
    when(executionUnitRunner.describeChild(runnerStep)).thenReturn(runnerStepDescription);
    runNotifier = mock(RunNotifier.class);
    jUnitReporter.startExecutionUnit(executionUnitRunner, runNotifier);
    jUnitReporter.startOfScenarioLifeCycle(mock(Scenario.class));
    jUnitReporter.step(runnerStep);
    jUnitReporter.match(mock(Match.class));
    verify(runNotifier).fireTestStarted(executionUnitRunner.getDescription());
    verify(runNotifier).fireTestStarted(runnerStepDescription);
}
Also used : Description(org.junit.runner.Description) RunNotifier(org.junit.runner.notification.RunNotifier) Step(gherkin.formatter.model.Step) Scenario(gherkin.formatter.model.Scenario) Match(gherkin.formatter.model.Match) Test(org.junit.Test)

Example 30 with Step

use of gherkin.formatter.model.Step in project cucumber-jvm by cucumber.

the class ExecutionUnitRunner method getDescription.

@Override
public Description getDescription() {
    if (description == null) {
        description = Description.createSuiteDescription(getName(), cucumberScenario.getGherkinModel());
        if (cucumberScenario.getCucumberBackground() != null) {
            for (Step backgroundStep : cucumberScenario.getCucumberBackground().getSteps()) {
                // We need to make a copy of that step, so we have a unique one per scenario
                Step copy = new Step(backgroundStep.getComments(), backgroundStep.getKeyword(), backgroundStep.getName(), backgroundStep.getLine(), backgroundStep.getRows(), backgroundStep.getDocString());
                description.addChild(describeChild(copy));
                runnerSteps.add(copy);
            }
        }
        for (Step step : getChildren()) {
            description.addChild(describeChild(step));
            runnerSteps.add(step);
        }
    }
    return description;
}
Also used : Step(gherkin.formatter.model.Step)

Aggregations

Step (gherkin.formatter.model.Step)50 Test (org.junit.Test)34 LocalizedXStreams (cucumber.runtime.xstream.LocalizedXStreams)9 Argument (gherkin.formatter.Argument)9 ExamplesTableRow (gherkin.formatter.model.ExamplesTableRow)7 Scenario (gherkin.formatter.model.Scenario)7 DocString (gherkin.formatter.model.DocString)6 Description (org.junit.runner.Description)6 I18n (gherkin.I18n)5 CucumberFeature (cucumber.runtime.model.CucumberFeature)4 DataTableRow (gherkin.formatter.model.DataTableRow)4 Match (gherkin.formatter.model.Match)4 CucumberException (cucumber.runtime.CucumberException)3 SnippetGenerator (cucumber.runtime.snippets.SnippetGenerator)3 Tag (gherkin.formatter.model.Tag)3 GherkinStep (org.jetbrains.plugins.cucumber.psi.GherkinStep)3 RunNotifier (org.junit.runner.notification.RunNotifier)3 Given (cucumber.api.java.en.Given)2 StepDefinition (cucumber.runtime.StepDefinition)2 StepDefinitionMatch (cucumber.runtime.StepDefinitionMatch)2