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;
}
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();
}
}
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());
}
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);
}
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);
}
Aggregations