use of gherkin.formatter.Formatter in project cucumber-jvm by cucumber.
the class FormatterMissingLifecycleMethods method set_monochrome_on_color_aware_formatters.
@Test
public void set_monochrome_on_color_aware_formatters() throws Exception {
PluginFactory factory = mock(PluginFactory.class);
Formatter colorAwareFormatter = mock(Formatter.class, withSettings().extraInterfaces(ColorAware.class));
when(factory.create("progress")).thenReturn(colorAwareFormatter);
RuntimeOptions options = new RuntimeOptions(new Env(), factory, asList("--monochrome", "--plugin", "progress"));
options.getPlugins();
verify((ColorAware) colorAwareFormatter).setMonochrome(true);
}
use of gherkin.formatter.Formatter in project cucumber-jvm by cucumber.
the class Runtime method run.
/**
* This is the main entry point. Used from CLI, but not from JUnit.
*/
public void run() throws IOException {
// Make sure all features parse before initialising any reporters/formatters
List<CucumberFeature> features = runtimeOptions.cucumberFeatures(resourceLoader);
// TODO: This is duplicated in cucumber.api.android.CucumberInstrumentationCore - refactor or keep uptodate
Formatter formatter = runtimeOptions.formatter(classLoader);
Reporter reporter = runtimeOptions.reporter(classLoader);
StepDefinitionReporter stepDefinitionReporter = runtimeOptions.stepDefinitionReporter(classLoader);
glue.reportStepDefinitions(stepDefinitionReporter);
for (CucumberFeature cucumberFeature : features) {
cucumberFeature.run(formatter, reporter, this);
}
formatter.done();
formatter.close();
printSummary();
}
use of gherkin.formatter.Formatter 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();
}
use of gherkin.formatter.Formatter in project cucumber-jvm by cucumber.
the class FeatureBuilder method parse.
public void parse(Resource resource, List<Object> filters) {
String gherkin = read(resource);
String checksum = checksum(gherkin);
String path = pathsByChecksum.get(checksum);
if (path != null) {
return;
}
pathsByChecksum.put(checksum, resource.getPath());
Formatter formatter = this;
if (!filters.isEmpty()) {
formatter = new FilterFormatter(this, filters);
}
Parser parser = new Parser(formatter);
try {
parser.parse(gherkin, convertFileSeparatorToForwardSlash(resource.getPath()), 0);
} catch (Exception e) {
throw new CucumberException(String.format("Error parsing feature file %s", convertFileSeparatorToForwardSlash(resource.getPath())), e);
}
I18n i18n = parser.getI18nLanguage();
if (currentCucumberFeature != null) {
// The current feature may be null if we used a very restrictive filter, say a tag that isn't used.
// Might also happen if the feature file itself is empty.
currentCucumberFeature.setI18n(i18n);
}
}
use of gherkin.formatter.Formatter in project cucumber-jvm by cucumber.
the class CucumberExecutor method execute.
/**
* Runs the cucumber scenarios with the specified arguments.
*/
public void execute() {
runtimeOptions.addPlugin(new AndroidInstrumentationReporter(runtime, instrumentation, getNumberOfConcreteScenarios()));
runtimeOptions.addPlugin(new AndroidLogcatReporter(runtime, TAG));
// TODO: This is duplicated in info.cucumber.Runtime.
final Reporter reporter = runtimeOptions.reporter(classLoader);
final Formatter formatter = runtimeOptions.formatter(classLoader);
final StepDefinitionReporter stepDefinitionReporter = runtimeOptions.stepDefinitionReporter(classLoader);
runtime.getGlue().reportStepDefinitions(stepDefinitionReporter);
for (final CucumberFeature cucumberFeature : cucumberFeatures) {
cucumberFeature.run(formatter, reporter, runtime);
}
formatter.done();
formatter.close();
}
Aggregations