use of io.cucumber.core.runner.ClockStub in project cucumber-jvm by cucumber.
the class PluginFactoryTest method plugin_does_not_buffer_its_output.
@Test
void plugin_does_not_buffer_its_output() {
PrintStream previousSystemOut = System.out;
OutputStream mockSystemOut = new ByteArrayOutputStream();
try {
System.setOut(new PrintStream(mockSystemOut));
// Need to create a new plugin factory here since we need it to pick
// up the new value of System.out
fc = new PluginFactory();
PluginOption option = parse("progress");
ProgressFormatter plugin = (ProgressFormatter) fc.create(option);
EventBus bus = new TimeServiceEventBus(new ClockStub(ZERO), UUID::randomUUID);
plugin.setEventPublisher(bus);
Result result = new Result(Status.PASSED, ZERO, null);
TestStepFinished event = new TestStepFinished(bus.getInstant(), mock(TestCase.class), mock(PickleStepTestStep.class), result);
bus.send(event);
assertThat(mockSystemOut.toString(), is(not(equalTo(""))));
} finally {
System.setOut(previousSystemOut);
}
}
use of io.cucumber.core.runner.ClockStub in project cucumber-jvm by cucumber.
the class JsonParallelRuntimeTest method testSingleFeature.
@Test
void testSingleFeature() {
ByteArrayOutputStream parallel = new ByteArrayOutputStream();
Runtime.builder().withRuntimeOptions(new RuntimeOptionsBuilder().setThreads(3).addFeature(FeatureWithLines.parse("src/test/resources/io/cucumber/core/plugin/JsonPrettyFormatterTest.feature")).build()).withAdditionalPlugins(new JsonFormatter(parallel)).withEventBus(new TimeServiceEventBus(new ClockStub(ZERO), UUID::randomUUID)).build().run();
ByteArrayOutputStream serial = new ByteArrayOutputStream();
Runtime.builder().withRuntimeOptions(new RuntimeOptionsBuilder().setThreads(1).addFeature(FeatureWithLines.parse("src/test/resources/io/cucumber/core/plugin/JsonPrettyFormatterTest.feature")).build()).withAdditionalPlugins(new JsonFormatter(serial)).withEventBus(new TimeServiceEventBus(new ClockStub(ZERO), UUID::randomUUID)).build().run();
assertThat(parallel.toString(), sameJSONAs(serial.toString()).allowingAnyArrayOrdering());
}
use of io.cucumber.core.runner.ClockStub in project cucumber-jvm by cucumber.
the class JsonParallelRuntimeTest method testMultipleFeatures.
@Test
void testMultipleFeatures() {
ByteArrayOutputStream parallel = new ByteArrayOutputStream();
Runtime.builder().withRuntimeOptions(new RuntimeOptionsBuilder().setThreads(3).addFeature(FeatureWithLines.parse("src/test/resources/io/cucumber/core/plugin/JsonPrettyFormatterTest.feature")).addFeature(FeatureWithLines.parse("src/test/resources/io/cucumber/core/plugin/FormatterInParallel.feature")).build()).withAdditionalPlugins(new JsonFormatter(parallel)).withEventBus(new TimeServiceEventBus(new ClockStub(ZERO), UUID::randomUUID)).build().run();
ByteArrayOutputStream serial = new ByteArrayOutputStream();
Runtime.builder().withRuntimeOptions(new RuntimeOptionsBuilder().setThreads(1).addFeature(FeatureWithLines.parse("src/test/resources/io/cucumber/core/plugin/JsonPrettyFormatterTest.feature")).addFeature(FeatureWithLines.parse("src/test/resources/io/cucumber/core/plugin/FormatterInParallel.feature")).build()).withAdditionalPlugins(new JsonFormatter(serial)).withEventBus(new TimeServiceEventBus(new ClockStub(ZERO), UUID::randomUUID)).build().run();
assertThat(parallel.toString(), sameJSONAs(serial.toString()).allowingAnyArrayOrdering());
}
Aggregations