Search in sources :

Example 41 with Step

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

the class UndefinedStepsTrackerTest method removes_duplicates.

@Test
public void removes_duplicates() {
    Backend backend = new TestBackend();
    UndefinedStepsTracker tracker = new UndefinedStepsTracker();
    tracker.storeStepKeyword(new Step(null, "Given ", "A", 1, null, null), ENGLISH);
    tracker.addUndefinedStep(new Step(null, "Given ", "B", 1, null, null), ENGLISH);
    tracker.addUndefinedStep(new Step(null, "Given ", "B", 1, null, null), ENGLISH);
    assertEquals("[Given ^B$]", tracker.getSnippets(asList(backend), functionNameGenerator).toString());
}
Also used : Step(gherkin.formatter.model.Step) Test(org.junit.Test)

Example 42 with Step

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

the class UndefinedStepsTrackerTest method star_keyword_becomes_given_when_no_previous_step.

@Test
public void star_keyword_becomes_given_when_no_previous_step() {
    Backend backend = new TestBackend();
    UndefinedStepsTracker tracker = new UndefinedStepsTracker();
    tracker.addUndefinedStep(new Step(null, "* ", "A", 1, null, null), ENGLISH);
    assertEquals("[Given ^A$]", tracker.getSnippets(asList(backend), functionNameGenerator).toString());
}
Also used : Step(gherkin.formatter.model.Step) Test(org.junit.Test)

Example 43 with Step

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

the class UndefinedStepsTrackerTest method snippets_are_generated_for_correct_locale.

@Test
public void snippets_are_generated_for_correct_locale() throws Exception {
    Backend backend = new TestBackend();
    UndefinedStepsTracker tracker = new UndefinedStepsTracker();
    tracker.addUndefinedStep(new Step(null, "Если ", "Б", 1, null, null), new I18n("ru"));
    assertEquals("[Если ^Б$]", tracker.getSnippets(asList(backend), functionNameGenerator).toString());
}
Also used : Step(gherkin.formatter.model.Step) I18n(gherkin.I18n) Test(org.junit.Test)

Example 44 with Step

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

the class StepDefinitionMatchTest method gives_nice_error_message_when_conversion_fails.

@Test
public void gives_nice_error_message_when_conversion_fails() throws Throwable {
    StepDefinition stepDefinition = mock(StepDefinition.class);
    when(stepDefinition.getParameterCount()).thenReturn(1);
    when(stepDefinition.getParameterType(0, String.class)).thenReturn(new ParameterInfo(Thang.class, null, null, null));
    Step stepWithoutDocStringOrTable = mock(Step.class);
    when(stepWithoutDocStringOrTable.getDocString()).thenReturn(null);
    when(stepWithoutDocStringOrTable.getRows()).thenReturn(null);
    StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(Arrays.asList(new Argument(0, "blah")), stepDefinition, "some.feature", stepWithoutDocStringOrTable, new LocalizedXStreams(classLoader));
    try {
        stepDefinitionMatch.runStep(ENGLISH);
        fail();
    } catch (CucumberException expected) {
        assertEquals("Don't know how to convert \"blah\" into cucumber.runtime.StepDefinitionMatchTest$Thang.\n" + "Try writing your own converter:\n" + "\n" + "@cucumber.deps.com.thoughtworks.xstream.annotations.XStreamConverter(ThangConverter.class)\n" + "public class Thang {}\n", expected.getMessage());
    }
}
Also used : Argument(gherkin.formatter.Argument) Step(gherkin.formatter.model.Step) LocalizedXStreams(cucumber.runtime.xstream.LocalizedXStreams) Test(org.junit.Test)

Example 45 with Step

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

the class CucumberScenarioOutlineTest method replaces_tokens_in_step_names.

@Test
public void replaces_tokens_in_step_names() {
    Step outlineStep = new Step(C, null, "I have <n> cukes", 0, null, null);
    Step exampleStep = CucumberScenarioOutline.createExampleStep(outlineStep, new ExamplesTableRow(C, asList("n"), 1, ""), new ExamplesTableRow(C, asList("10"), 1, ""));
    assertEquals("I have 10 cukes", exampleStep.getName());
}
Also used : ExamplesTableRow(gherkin.formatter.model.ExamplesTableRow) 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