Search in sources :

Example 1 with PrettyFormatter

use of gherkin.formatter.PrettyFormatter in project cucumber-jvm by cucumber.

the class DataTable method toString.

@Override
public String toString() {
    StringBuilder result = new StringBuilder();
    PrettyFormatter pf = new PrettyFormatter(result, true, false);
    pf.table(getGherkinRows());
    pf.eof();
    return result.toString();
}
Also used : PrettyFormatter(gherkin.formatter.PrettyFormatter)

Example 2 with PrettyFormatter

use of gherkin.formatter.PrettyFormatter in project cucumber-jvm by cucumber.

the class BackgroundTest method should_run_background.

@Test
public void should_run_background() throws IOException {
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    RuntimeOptions runtimeOptions = new RuntimeOptions("");
    Runtime runtime = new Runtime(new ClasspathResourceLoader(classLoader), classLoader, asList(mock(Backend.class)), runtimeOptions);
    CucumberFeature feature = feature("test.feature", "" + "Feature:\n" + "  Background:\n" + "    Given b\n" + "  Scenario:\n" + "    When s\n");
    StringBuilder out = new StringBuilder();
    PrettyFormatter pretty = new PrettyFormatter(out, true, true);
    feature.run(pretty, pretty, runtime);
    String expectedOutput = "" + "Feature: \n" + "\n" + "  Background:  # test.feature:2\n" + "    Given b\n" + "\n" + "  Scenario:  # test.feature:4\n" + "    When s\n";
    assertEquals(expectedOutput, out.toString());
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) ClasspathResourceLoader(cucumber.runtime.io.ClasspathResourceLoader) PrettyFormatter(gherkin.formatter.PrettyFormatter) Test(org.junit.Test)

Aggregations

PrettyFormatter (gherkin.formatter.PrettyFormatter)2 ClasspathResourceLoader (cucumber.runtime.io.ClasspathResourceLoader)1 CucumberFeature (cucumber.runtime.model.CucumberFeature)1 Test (org.junit.Test)1