Search in sources :

Example 21 with Step

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

the class JUnitReporterTest method forward_calls_to_formatter_interface_methods.

@Test
public void forward_calls_to_formatter_interface_methods() throws Exception {
    String uri = "uri";
    Feature feature = mock(Feature.class);
    Background background = mock(Background.class);
    ScenarioOutline scenarioOutline = mock(ScenarioOutline.class);
    Examples examples = mock(Examples.class);
    Scenario scenario = mock(Scenario.class);
    Step step = mock(Step.class);
    Formatter formatter = mock(Formatter.class);
    jUnitReporter = new JUnitReporter(mock(Reporter.class), formatter, false, new JUnitOptions(Collections.<String>emptyList()));
    jUnitReporter.uri(uri);
    jUnitReporter.feature(feature);
    jUnitReporter.scenarioOutline(scenarioOutline);
    jUnitReporter.examples(examples);
    jUnitReporter.startOfScenarioLifeCycle(scenario);
    jUnitReporter.background(background);
    jUnitReporter.scenario(scenario);
    jUnitReporter.step(step);
    jUnitReporter.endOfScenarioLifeCycle(scenario);
    jUnitReporter.eof();
    jUnitReporter.done();
    jUnitReporter.close();
    verify(formatter).uri(uri);
    verify(formatter).feature(feature);
    verify(formatter).scenarioOutline(scenarioOutline);
    verify(formatter).examples(examples);
    verify(formatter).startOfScenarioLifeCycle(scenario);
    ;
    verify(formatter).background(background);
    verify(formatter).scenario(scenario);
    verify(formatter).step(step);
    verify(formatter).endOfScenarioLifeCycle(scenario);
    verify(formatter).eof();
    verify(formatter).done();
    verify(formatter).close();
}
Also used : Background(gherkin.formatter.model.Background) ScenarioOutline(gherkin.formatter.model.ScenarioOutline) Formatter(gherkin.formatter.Formatter) Step(gherkin.formatter.model.Step) Feature(gherkin.formatter.model.Feature) Examples(gherkin.formatter.model.Examples) Scenario(gherkin.formatter.model.Scenario) Test(org.junit.Test)

Example 22 with Step

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

the class TestNgReporter method logResult.

private void logResult(Result result) {
    String timing = computeTiming(result);
    Step step;
    if (steps.isEmpty()) {
        step = new Step(null, "MISMATCH BETWEEN STEPS AND RESULTS", "", 0, null, null);
    } else {
        step = steps.pop();
    }
    String format = "%s %s (%s%s)";
    String message = String.format(format, step.getKeyword(), step.getName(), result.getStatus(), timing);
    logDiv(message, "result");
}
Also used : Step(gherkin.formatter.model.Step)

Example 23 with Step

use of gherkin.formatter.model.Step in project intellij-plugins by JetBrains.

the class Java8StepDefinitionCreator method buildStepDefinitionByStep.

private static PsiElement buildStepDefinitionByStep(@NotNull final GherkinStep step, Language language) {
    final Step cucumberStep = new Step(new ArrayList<>(), step.getKeyword().getText(), step.getStepName(), 0, null, null);
    final SnippetGenerator generator = new SnippetGenerator(new Java8Snippet());
    final String snippet = generator.getSnippet(cucumberStep, new FunctionNameGenerator(new CamelCaseConcatenator())).replace("PendingException", CucumberJavaUtil.getCucumberPendingExceptionFqn(step)).replaceAll("\\\\\\\\", "\\\\").replaceAll("\\\\d", "\\\\\\\\d");
    JVMElementFactory factory = JVMElementFactories.requireFactory(language, step.getProject());
    return factory.createExpressionFromText(snippet, step);
}
Also used : CamelCaseConcatenator(cucumber.runtime.snippets.CamelCaseConcatenator) SnippetGenerator(cucumber.runtime.snippets.SnippetGenerator) FunctionNameGenerator(cucumber.runtime.snippets.FunctionNameGenerator) Step(gherkin.formatter.model.Step) GherkinStep(org.jetbrains.plugins.cucumber.psi.GherkinStep)

Example 24 with Step

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

the class ClojureSnippetTest method generatesPlainSnippet.

@Test
public void generatesPlainSnippet() throws Exception {
    Step step = new Step(NO_COMMENTS, "Given ", "I have 4 cukes in my \"big\" belly", 0, null, null);
    String snippet = newBackend().getSnippet(step, null);
    String expected = "" + "(Given #\"^I have (\\d+) cukes in my \\\"([^\\\"]*)\\\" belly$\" [arg1 arg2]\n" + "  (comment  Write code here that turns the phrase above into concrete actions  )\n" + "  (throw (cucumber.api.PendingException.)))\n";
    assertEquals(expected, snippet);
}
Also used : Step(gherkin.formatter.model.Step) Test(org.junit.Test)

Example 25 with Step

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

the class RuntimeTest method non_strict_with_undefined_steps.

@Test
public void non_strict_with_undefined_steps() {
    Runtime runtime = createNonStrictRuntime();
    runtime.undefinedStepsTracker.addUndefinedStep(new Step(null, "Given ", "A", 1, null, null), ENGLISH);
    assertEquals(0x0, runtime.exitStatus());
}
Also used : Step(gherkin.formatter.model.Step) 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