1
1
package io .cucumber .core .plugin ;
2
2
3
3
import io .cucumber .messages .types .Envelope ;
4
- import io .cucumber .messages .types .TestCase ;
5
4
import io .cucumber .messages .types .TestRunFinished ;
6
- import io .cucumber .messages .types .TestStep ;
7
5
import io .cucumber .messages .types .TestStepFinished ;
8
6
import io .cucumber .messages .types .TestStepResultStatus ;
9
7
import io .cucumber .plugin .ColorAware ;
15
13
import java .io .PrintWriter ;
16
14
import java .nio .charset .StandardCharsets ;
17
15
import java .util .EnumMap ;
18
- import java .util .HashMap ;
19
16
import java .util .Map ;
20
17
21
18
import static io .cucumber .messages .types .TestStepResultStatus .AMBIGUOUS ;
28
25
29
26
public final class ProgressFormatter implements ConcurrentEventListener , ColorAware {
30
27
31
- private final Map <String , TestStep > testStepById = new HashMap <>();
32
28
private final Map <TestStepResultStatus , String > chars = new EnumMap <>(TestStepResultStatus .class );
33
29
private final Map <TestStepResultStatus , AnsiEscapes > escapes = new EnumMap <>(TestStepResultStatus .class );
34
30
private final PrintWriter writer ;
35
31
private boolean monochrome = false ;
36
-
32
+
37
33
public ProgressFormatter (OutputStream out ) {
38
34
this .writer = createPrintWriter (out );
39
-
35
+
40
36
chars .put (PASSED , "." );
41
37
chars .put (UNDEFINED , "U" );
42
38
chars .put (PENDING , "P" );
@@ -69,20 +65,12 @@ public void setMonochrome(boolean monochrome) {
69
65
@ Override
70
66
public void setEventPublisher (EventPublisher publisher ) {
71
67
publisher .registerHandlerFor (Envelope .class , event -> {
72
- event .getTestCase ().ifPresent (this ::updateTestCase );
73
68
event .getTestStepFinished ().ifPresent (this ::handleTestStepFinished );
74
69
event .getTestRunFinished ().ifPresent (this ::handleTestRunFinished );
75
70
});
76
71
}
77
72
78
- private void updateTestCase (TestCase event ) {
79
- event .getTestSteps ().forEach (testStep -> testStepById .put (testStep .getId (), testStep ));
80
- }
81
-
82
73
private void handleTestStepFinished (TestStepFinished event ) {
83
- if (!includeStep (event )) {
84
- return ;
85
- }
86
74
TestStepResultStatus status = event .getTestStepResult ().getStatus ();
87
75
// Prevent tearing in output when multiple threads write to System.out
88
76
StringBuilder buffer = new StringBuilder ();
@@ -97,15 +85,6 @@ private void handleTestStepFinished(TestStepFinished event) {
97
85
writer .flush ();
98
86
}
99
87
100
- private boolean includeStep (TestStepFinished testStepFinished ) {
101
- TestStepResultStatus status = testStepFinished .getTestStepResult ().getStatus ();
102
- if (status == FAILED ) {
103
- return true ;
104
- }
105
- TestStep testStep = testStepById .get (testStepFinished .getTestStepId ());
106
- return testStep != null && testStep .getPickleStepId ().isPresent ();
107
- }
108
-
109
88
private void handleTestRunFinished (TestRunFinished testRunFinished ) {
110
89
writer .println ();
111
90
writer .close ();
0 commit comments