|
4 | 4 | import io.cucumber.core.eventbus.EventBus;
|
5 | 5 | import io.cucumber.messages.types.Envelope;
|
6 | 6 | import io.cucumber.messages.types.TestStepResult;
|
7 |
| -import io.cucumber.plugin.event.Result; |
8 |
| -import io.cucumber.plugin.event.Status; |
9 | 7 | import io.cucumber.plugin.event.TestCase;
|
10 |
| -import io.cucumber.plugin.event.TestStepFinished; |
11 |
| -import io.cucumber.plugin.event.TestStepStarted; |
| 8 | +import io.cucumber.plugin.event.*; |
12 | 9 |
|
13 | 10 | import java.io.ByteArrayOutputStream;
|
14 | 11 | import java.io.PrintStream;
|
|
21 | 18 | import static io.cucumber.core.exception.UnrecoverableExceptions.rethrowIfUnrecoverable;
|
22 | 19 | import static io.cucumber.core.runner.ExecutionMode.SKIP;
|
23 | 20 | import static io.cucumber.core.runner.TestAbortedExceptions.createIsTestAbortedExceptionPredicate;
|
24 |
| -import static io.cucumber.core.runner.TestStepResultStatus.from; |
25 |
| -import static io.cucumber.messages.TimeConversion.javaDurationToDuration; |
26 |
| -import static io.cucumber.messages.TimeConversion.javaInstantToTimestamp; |
| 21 | +import static io.cucumber.core.runner.TestStepResultStatusMapper.from; |
| 22 | +import static io.cucumber.messages.Convertor.toMessage; |
27 | 23 | import static java.time.Duration.ZERO;
|
28 | 24 |
|
29 | 25 | abstract class TestStep implements io.cucumber.plugin.event.TestStep {
|
@@ -72,11 +68,10 @@ ExecutionMode run(TestCase testCase, EventBus bus, TestCaseState state, Executio
|
72 | 68 |
|
73 | 69 | private void emitTestStepStarted(TestCase testCase, EventBus bus, UUID textExecutionId, Instant startTime) {
|
74 | 70 | bus.send(new TestStepStarted(startTime, testCase, this));
|
75 |
| - Envelope envelope = new Envelope(); |
76 |
| - envelope.setTestStepStarted(new io.cucumber.messages.types.TestStepStarted( |
77 |
| - textExecutionId.toString(), |
78 |
| - id.toString(), |
79 |
| - javaInstantToTimestamp(startTime))); |
| 71 | + Envelope envelope = Envelope.of(new io.cucumber.messages.types.TestStepStarted( |
| 72 | + textExecutionId.toString(), |
| 73 | + id.toString(), |
| 74 | + toMessage(startTime))); |
80 | 75 | bus.send(envelope);
|
81 | 76 | }
|
82 | 77 |
|
@@ -117,19 +112,18 @@ private void emitTestStepFinished(
|
117 | 112 | ) {
|
118 | 113 | bus.send(new TestStepFinished(stopTime, testCase, this, result));
|
119 | 114 |
|
120 |
| - TestStepResult testStepResult = new TestStepResult(); |
121 |
| - if (result.getError() != null) { |
122 |
| - testStepResult.setMessage(extractStackTrace(result.getError())); |
123 |
| - } |
124 |
| - testStepResult.setStatus(from(result.getStatus())); |
125 |
| - testStepResult.setDuration(javaDurationToDuration(duration)); |
126 |
| - |
127 |
| - Envelope envelope = new Envelope(); |
128 |
| - envelope.setTestStepFinished(new io.cucumber.messages.types.TestStepFinished( |
129 |
| - textExecutionId.toString(), |
130 |
| - id.toString(), |
131 |
| - testStepResult, |
132 |
| - javaInstantToTimestamp(stopTime))); |
| 115 | + TestStepResult testStepResult = new TestStepResult( |
| 116 | + toMessage(duration), |
| 117 | + result.getError() != null ? extractStackTrace(result.getError()) : null, |
| 118 | + from(result.getStatus()), |
| 119 | + result.getError() != null ? toMessage(result.getError()) : null |
| 120 | + ); |
| 121 | + |
| 122 | + Envelope envelope = Envelope.of(new io.cucumber.messages.types.TestStepFinished( |
| 123 | + textExecutionId.toString(), |
| 124 | + id.toString(), |
| 125 | + testStepResult, |
| 126 | + toMessage(stopTime))); |
133 | 127 | bus.send(envelope);
|
134 | 128 | }
|
135 | 129 |
|
|
0 commit comments