Search in sources :

Example 1 with PickleRunner

use of io.cucumber.junit.PickleRunners.PickleRunner in project cucumber-jvm by cucumber.

the class PickleRunnerWithStepDescriptionsTest method shouldUseStepKeyworkAndNameForChildName.

@Test
void shouldUseStepKeyworkAndNameForChildName() {
    List<Pickle> pickles = picklesFromFeature("featurePath", "" + "Feature: feature name\n" + "  Scenario: scenario name\n" + "    Then it works\n");
    PickleRunner runner = PickleRunners.withStepDescriptions(context, pickles.get(0), null, createJunitOptions());
    assertEquals("it works", runner.getDescription().getChildren().get(0).getMethodName());
}
Also used : PickleRunner(io.cucumber.junit.PickleRunners.PickleRunner) Pickle(io.cucumber.core.gherkin.Pickle) Test(org.junit.jupiter.api.Test)

Example 2 with PickleRunner

use of io.cucumber.junit.PickleRunners.PickleRunner in project cucumber-jvm by cucumber.

the class PickleRunnerWithStepDescriptionsTest method shouldIncludeScenarioNameAsClassNameInStepDescriptions.

@Test
void shouldIncludeScenarioNameAsClassNameInStepDescriptions() {
    Feature features = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: In cucumber.junit\n" + "  Scenario: first\n" + "    When step\n" + "    Then another step\n" + "\n" + "  Scenario: second\n" + "    When step\n" + "    Then another step\n");
    PickleRunner runner = PickleRunners.withStepDescriptions(context, features.getPickles().get(0), null, createJunitOptions());
    // fish out the data from runner
    Description runnerDescription = runner.getDescription();
    Description stepDescription = runnerDescription.getChildren().get(0);
    assertEquals("first", stepDescription.getClassName());
    assertEquals("step", stepDescription.getMethodName());
    assertEquals("step(first)", stepDescription.getDisplayName());
}
Also used : PickleRunner(io.cucumber.junit.PickleRunners.PickleRunner) Description(org.junit.runner.Description) Feature(io.cucumber.core.gherkin.Feature) TestPickleBuilder.picklesFromFeature(io.cucumber.junit.TestPickleBuilder.picklesFromFeature) Test(org.junit.jupiter.api.Test)

Example 3 with PickleRunner

use of io.cucumber.junit.PickleRunners.PickleRunner in project cucumber-jvm by cucumber.

the class PickleRunnerWithStepDescriptionsTest method shouldConvertTextFromFeatureFileForNamesWithFilenameCompatibleNameOption.

@Test
void shouldConvertTextFromFeatureFileForNamesWithFilenameCompatibleNameOption() {
    List<Pickle> pickles = picklesFromFeature("featurePath", "" + "Feature: feature name\n" + "  Scenario: scenario name\n" + "    Then it works\n");
    PickleRunner runner = PickleRunners.withStepDescriptions(context, pickles.get(0), null, createFileNameCompatibleJunitOptions());
    assertEquals("scenario_name", runner.getDescription().getDisplayName());
    assertEquals("scenario_name", runner.getDescription().getChildren().get(0).getClassName());
    assertEquals("it_works", runner.getDescription().getChildren().get(0).getMethodName());
}
Also used : PickleRunner(io.cucumber.junit.PickleRunners.PickleRunner) Pickle(io.cucumber.core.gherkin.Pickle) Test(org.junit.jupiter.api.Test)

Example 4 with PickleRunner

use of io.cucumber.junit.PickleRunners.PickleRunner in project cucumber-jvm by cucumber.

the class PickleRunnerWithNoStepDescriptionsTest method shouldConvertTextFromFeatureFileWithRussianLanguage.

@Test
void shouldConvertTextFromFeatureFileWithRussianLanguage() {
    List<Pickle> pickles = TestPickleBuilder.picklesFromFeature("featurePath", "" + "#language:ru\n" + "Функция: имя функции\n" + "  Сценарий: имя сценария\n" + "    Тогда он работает\n");
    PickleRunner runner = PickleRunners.withNoStepDescriptions("имя функции", context, pickles.get(0), null, createFileNameCompatibleJUnitOptions());
    assertThat(runner.getDescription().getDisplayName(), is(equalTo("____________(___________)")));
}
Also used : PickleRunner(io.cucumber.junit.PickleRunners.PickleRunner) Pickle(io.cucumber.core.gherkin.Pickle) Test(org.junit.jupiter.api.Test)

Example 5 with PickleRunner

use of io.cucumber.junit.PickleRunners.PickleRunner in project cucumber-jvm by cucumber.

the class PickleRunnerWithNoStepDescriptionsTest method shouldUseScenarioNameWithFeatureNameAsClassNameForDisplayName.

@Test
void shouldUseScenarioNameWithFeatureNameAsClassNameForDisplayName() {
    List<Pickle> pickles = TestPickleBuilder.picklesFromFeature("featurePath", "" + "Feature: feature name\n" + "  Scenario: scenario name\n" + "    Then it works\n");
    PickleRunner runner = PickleRunners.withNoStepDescriptions("feature name", context, pickles.get(0), null, createJunitOptions());
    assertThat(runner.getDescription().getDisplayName(), is(equalTo("scenario name(feature name)")));
}
Also used : PickleRunner(io.cucumber.junit.PickleRunners.PickleRunner) Pickle(io.cucumber.core.gherkin.Pickle) Test(org.junit.jupiter.api.Test)

Aggregations

PickleRunner (io.cucumber.junit.PickleRunners.PickleRunner)7 Test (org.junit.jupiter.api.Test)7 Pickle (io.cucumber.core.gherkin.Pickle)6 Feature (io.cucumber.core.gherkin.Feature)1 TestPickleBuilder.picklesFromFeature (io.cucumber.junit.TestPickleBuilder.picklesFromFeature)1 Description (org.junit.runner.Description)1