Search in sources :

Example 31 with Step

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

the class JUnitReporter method fetchAndCheckRunnerStep.

private Step fetchAndCheckRunnerStep() {
    Step scenarioStep = steps.remove(0);
    Step runnerStep = executionUnitRunner.getRunnerSteps().remove(0);
    if (!scenarioStep.getName().equals(runnerStep.getName())) {
        throw new CucumberException("Expected step: \"" + scenarioStep.getName() + "\" got step: \"" + runnerStep.getName() + "\"");
    }
    return runnerStep;
}
Also used : Step(gherkin.formatter.model.Step) CucumberException(cucumber.runtime.CucumberException)

Example 32 with Step

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

the class JUnitReporter method match.

public void match(Match match) {
    Step runnerStep = fetchAndCheckRunnerStep();
    Description description = executionUnitRunner.describeChild(runnerStep);
    stepNotifier = new EachTestNotifier(runNotifier, description);
    reporter.match(match);
    if (junitOptions.allowStartedIgnored()) {
        stepNotifier.fireTestStarted();
    }
}
Also used : Description(org.junit.runner.Description) EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier) Step(gherkin.formatter.model.Step)

Example 33 with Step

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

the class ExecutionUnitRunnerTest method shouldIncludeScenarioNameAsClassNameInStepDescriptions.

@Test
public void shouldIncludeScenarioNameAsClassNameInStepDescriptions() throws Exception {
    List<CucumberFeature> features = CucumberFeature.load(new ClasspathResourceLoader(this.getClass().getClassLoader()), asList("cucumber/runtime/junit/feature_with_same_steps_in_different_scenarios.feature"), Collections.emptyList());
    ExecutionUnitRunner runner = new ExecutionUnitRunner(null, (CucumberScenario) features.get(0).getFeatureElements().get(0), createStandardJUnitReporter());
    // fish out the data from runner
    Step step = runner.getChildren().get(0);
    Description runnerDescription = runner.getDescription();
    Description stepDescription = runnerDescription.getChildren().get(0);
    assertEquals("description includes scenario name as class name", runner.getName(), stepDescription.getClassName());
    assertEquals("description includes step keyword and name as method name", step.getKeyword() + step.getName(), stepDescription.getMethodName());
}
Also used : Description(org.junit.runner.Description) CucumberFeature(cucumber.runtime.model.CucumberFeature) ClasspathResourceLoader(cucumber.runtime.io.ClasspathResourceLoader) Step(gherkin.formatter.model.Step) Test(org.junit.Test)

Example 34 with Step

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

the class ExecutionUnitRunnerTest method shouldPopulateRunnerStepsWithStepsUsedInStepDescriptions.

@Test
public void shouldPopulateRunnerStepsWithStepsUsedInStepDescriptions() throws Exception {
    CucumberFeature cucumberFeature = TestFeatureBuilder.feature("featurePath", "" + "Feature: feature name\n" + "  Background:\n" + "    Given background step\n" + "  Scenario:\n" + "    Then scenario name\n");
    ExecutionUnitRunner runner = new ExecutionUnitRunner(null, (CucumberScenario) cucumberFeature.getFeatureElements().get(0), createStandardJUnitReporter());
    // fish out the data from runner
    Description runnerDescription = runner.getDescription();
    Description backgroundStepDescription = runnerDescription.getChildren().get(0);
    Description scenarioStepDescription = runnerDescription.getChildren().get(1);
    Step runnerBackgroundStep = runner.getRunnerSteps().get(0);
    Step runnerScenarioStep = runner.getRunnerSteps().get(1);
    assertDescriptionHasStepAsUniqueId(backgroundStepDescription, runnerBackgroundStep);
    assertDescriptionHasStepAsUniqueId(scenarioStepDescription, runnerScenarioStep);
}
Also used : Description(org.junit.runner.Description) CucumberFeature(cucumber.runtime.model.CucumberFeature) Step(gherkin.formatter.model.Step) Test(org.junit.Test)

Example 35 with Step

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

the class JUnitReporterTest method creates_step_notifier_with_step_from_execution_unit_runner.

@Test
public void creates_step_notifier_with_step_from_execution_unit_runner() throws Exception {
    Step runnerStep = mockStep("Step Name");
    Description runnerStepDescription = stepDescription(runnerStep);
    ExecutionUnitRunner executionUnitRunner = mockExecutionUnitRunner(runnerSteps(runnerStep));
    when(executionUnitRunner.describeChild(runnerStep)).thenReturn(runnerStepDescription);
    RunNotifier notifier = mock(RunNotifier.class);
    jUnitReporter = new JUnitReporter(mock(Reporter.class), mock(Formatter.class), false, new JUnitOptions(Collections.<String>emptyList()));
    jUnitReporter.startExecutionUnit(executionUnitRunner, notifier);
    jUnitReporter.startOfScenarioLifeCycle(mock(Scenario.class));
    jUnitReporter.step(mockStep("Step Name"));
    jUnitReporter.match(mock(Match.class));
    jUnitReporter.result(mockResult());
    verify(notifier).fireTestFinished(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)

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