Skip to content

Commit

Permalink
add 2 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
artysidorenko committed Aug 4, 2021
1 parent 6b34d6a commit 55eaa32
Showing 1 changed file with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.cucumber.core.stepexpression.StepExpression;
import io.cucumber.core.stepexpression.StepExpressionFactory;
import io.cucumber.core.stepexpression.StepTypeRegistry;
import io.cucumber.datatable.DataTable;
import org.junit.jupiter.api.Test;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -174,6 +175,75 @@ void should_print_tags() {
" Then second step # path/step_definitions.java:11\n"));
}

@Test
void should_print_table() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" +
"Feature: Test feature\n" +
" Scenario: Test Scenario\n" +
" Given first step\n" +
" | key1 | key2 |\n" +
" | value1 | value2 |\n" +
" | another1 | another2 |\n");

ByteArrayOutputStream out = new ByteArrayOutputStream();
Runtime.builder()
.withFeatureSupplier(new StubFeatureSupplier(feature))
.withAdditionalPlugins(new PrettyFormatter(out))
.withRuntimeOptions(new RuntimeOptionsBuilder().setMonochrome().build())
.withBackendSupplier(new StubBackendSupplier(
new StubStepDefinition("first step", "path/step_definitions.java:7", DataTable.class)))
.build()
.run();

assertThat(out, isBytesEqualTo("" +

"\n" +
"Scenario: Test Scenario # path/test.feature:2\n" +
" Given first step # path/step_definitions.java:7\n" +
" | key1 | key2 |\n" +
" | value1 | value2 |\n" +
" | another1 | another2 |\n"));
}

@Test
void should_print_multiple_tables() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" +
"Feature: Test feature\n" +
" Scenario: Test Scenario\n" +
" Given first step\n" +
" | key1 | key2 |\n" +
" | value1 | value2 |\n" +
" | another1 | another2 |\n" +
" Given second step\n" +
" | key3 | key4 |\n" +
" | value3 | value4 |\n" +
" | another3 | another4 |\n");

ByteArrayOutputStream out = new ByteArrayOutputStream();
Runtime.builder()
.withFeatureSupplier(new StubFeatureSupplier(feature))
.withAdditionalPlugins(new PrettyFormatter(out))
.withRuntimeOptions(new RuntimeOptionsBuilder().setMonochrome().build())
.withBackendSupplier(new StubBackendSupplier(
new StubStepDefinition("first step", "path/step_definitions.java:7", DataTable.class),
new StubStepDefinition("second step", "path/step_definitions.java:15", DataTable.class)))
.build()
.run();

assertThat(out, isBytesEqualTo("" +

"\n" +
"Scenario: Test Scenario # path/test.feature:2\n" +
" Given first step # path/step_definitions.java:7\n" +
" | key1 | key2 |\n" +
" | value1 | value2 |\n" +
" | another1 | another2 |\n" +
" Given second step # path/step_definitions.java:15\n" +
" | key3 | key4 |\n" +
" | value3 | value4 |\n" +
" | another3 | another4 |\n"));
}

@Test
void should_print_error_message_for_failed_steps() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" +
Expand Down

0 comments on commit 55eaa32

Please sign in to comment.