1
1
package io .cucumber .core .plugin ;
2
2
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 ;
3
11
import org .junit .jupiter .api .Test ;
4
12
5
13
import java .io .ByteArrayOutputStream ;
6
14
import java .io .PrintStream ;
7
15
import java .io .UnsupportedEncodingException ;
8
16
import java .nio .charset .StandardCharsets ;
17
+ import java .time .Clock ;
18
+ import java .time .Instant ;
19
+ import java .util .UUID ;
9
20
10
21
import static io .cucumber .core .plugin .BytesEqualTo .isBytesEqualTo ;
11
22
import static org .hamcrest .MatcherAssert .assertThat ;
@@ -15,9 +26,15 @@ class NoPublishFormatterTest {
15
26
public void should_print_banner () throws UnsupportedEncodingException {
16
27
ByteArrayOutputStream bytes = new ByteArrayOutputStream ();
17
28
PrintStream out = new PrintStream (bytes , false , StandardCharsets .UTF_8 .name ());
29
+ EventBus bus = new TimeServiceEventBus (Clock .systemUTC (), UUID ::randomUUID );
30
+
18
31
NoPublishFormatter noPublishFormatter = new NoPublishFormatter (out );
19
32
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
+
21
38
assertThat (bytes , isBytesEqualTo ("" +
22
39
"┌───────────────────────────────────────────────────────────────────────────────────┐\n " +
23
40
"│ Share your Cucumber Report with your team at https://reports.cucumber.io │\n " +
0 commit comments