use of gherkin.formatter.Reporter in project cucumber-jvm by cucumber.
the class JavaStepDefinitionTest method does_not_throw_ambiguous_when_nothing_is_ambiguous.
@Test
public void does_not_throw_ambiguous_when_nothing_is_ambiguous() throws Throwable {
backend.addStepDefinition(THREE_DISABLED_MICE.getAnnotation(Given.class), THREE_DISABLED_MICE);
Reporter reporter = new Reporter() {
@Override
public void before(Match match, Result result) {
throw new UnsupportedOperationException();
}
@Override
public void result(Result result) {
if (result.getError() != null) {
throw new RuntimeException(result.getError());
}
}
@Override
public void after(Match match, Result result) {
throw new UnsupportedOperationException();
}
@Override
public void match(Match match) {
}
@Override
public void embedding(String mimeType, byte[] data) {
}
@Override
public void write(String text) {
}
};
runtime.buildBackendWorlds(reporter, Collections.<Tag>emptySet(), mock(Scenario.class));
Tag tag = new Tag("@foo", 0);
Set<Tag> tags = asSet(tag);
runtime.runBeforeHooks(reporter, tags);
Step step = new Step(NO_COMMENTS, "Given ", "three blind mice", 1, null, null);
runtime.runStep("some.feature", step, reporter, ENGLISH);
assertTrue(defs.foo);
assertFalse(defs.bar);
}
use of gherkin.formatter.Reporter 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();
}
use of gherkin.formatter.Reporter in project cucumber-jvm by cucumber.
the class RuntimeTest method should_add_skipped_result_to_the_summary_counter.
@Test
public void should_add_skipped_result_to_the_summary_counter() throws Throwable {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Reporter reporter = mock(Reporter.class);
StepDefinitionMatch match = createExceptionThrowingMatch(new Exception());
Runtime runtime = createRuntimeWithMockedGlue(match, "--monochrome");
runScenario(reporter, runtime, stepCount(2));
runtime.printStats(new PrintStream(baos));
assertThat(baos.toString(), containsString(String.format("" + "1 Scenarios (1 failed)%n" + "2 Steps (1 failed, 1 skipped)%n")));
}
use of gherkin.formatter.Reporter in project cucumber-jvm by cucumber.
the class RuntimeTest method should_add_passed_result_to_the_summary_counter.
@Test
public void should_add_passed_result_to_the_summary_counter() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Reporter reporter = mock(Reporter.class);
StepDefinitionMatch match = mock(StepDefinitionMatch.class);
Runtime runtime = createRuntimeWithMockedGlue(match, "--monochrome");
runScenario(reporter, runtime, stepCount(1));
runtime.printStats(new PrintStream(baos));
assertThat(baos.toString(), startsWith(String.format("1 Scenarios (1 passed)%n" + "1 Steps (1 passed)%n")));
}
use of gherkin.formatter.Reporter in project cucumber-jvm by cucumber.
the class RuntimeTest method should_add_failed_result_to_the_summary_counter.
@Test
public void should_add_failed_result_to_the_summary_counter() throws Throwable {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Reporter reporter = mock(Reporter.class);
StepDefinitionMatch match = createExceptionThrowingMatch(new Exception());
Runtime runtime = createRuntimeWithMockedGlue(match, "--monochrome");
runScenario(reporter, runtime, stepCount(1));
runtime.printStats(new PrintStream(baos));
assertThat(baos.toString(), containsString(String.format("" + "1 Scenarios (1 failed)%n" + "1 Steps (1 failed)%n")));
}
Aggregations