11package io .cucumber .core .plugin ;
22
3+ import io .cucumber .core .eventbus .EventBus ;
4+ import io .cucumber .core .runtime .TimeServiceEventBus ;
5+ import io .cucumber .messages .types .Envelope ;
6+ import io .cucumber .messages .types .TestRunFinished ;
7+ import io .cucumber .messages .types .TestRunStarted ;
8+ import io .cucumber .messages .types .Timestamp ;
9+ import io .cucumber .plugin .event .EventHandler ;
10+ import io .cucumber .plugin .event .EventPublisher ;
311import org .junit .jupiter .api .Test ;
412
513import java .io .ByteArrayOutputStream ;
614import java .io .PrintStream ;
715import java .io .UnsupportedEncodingException ;
816import java .nio .charset .StandardCharsets ;
17+ import java .time .Clock ;
18+ import java .time .Instant ;
19+ import java .util .UUID ;
920
1021import static io .cucumber .core .plugin .BytesEqualTo .isBytesEqualTo ;
1122import static org .hamcrest .MatcherAssert .assertThat ;
@@ -15,9 +26,15 @@ class NoPublishFormatterTest {
1526 public void should_print_banner () throws UnsupportedEncodingException {
1627 ByteArrayOutputStream bytes = new ByteArrayOutputStream ();
1728 PrintStream out = new PrintStream (bytes , false , StandardCharsets .UTF_8 .name ());
29+ EventBus bus = new TimeServiceEventBus (Clock .systemUTC (), UUID ::randomUUID );
30+
1831 NoPublishFormatter noPublishFormatter = new NoPublishFormatter (out );
1932 noPublishFormatter .setMonochrome (true );
20- noPublishFormatter .printBanner ();
33+ noPublishFormatter .setEventPublisher (bus );
34+
35+ bus .send (Envelope .of (new TestRunStarted (new Timestamp (0L , 0L ))));
36+ bus .send (Envelope .of (new TestRunFinished (null , true , new Timestamp (0L , 0L ))));
37+
2138 assertThat (bytes , isBytesEqualTo ("" +
2239 "┌───────────────────────────────────────────────────────────────────────────────────┐\n " +
2340 "│ Share your Cucumber Report with your team at https://reports.cucumber.io │\n " +
0 commit comments