|
3 | 3 | import static org.testng.Reporter.getCurrentTestResult;
|
4 | 4 | import static org.testng.Reporter.log;
|
5 | 5 |
|
6 |
| -import cucumber.runtime.Utils; |
7 | 6 | import cucumber.api.Result;
|
8 | 7 | import cucumber.api.event.EventHandler;
|
9 | 8 | import cucumber.api.event.EventPublisher;
|
10 | 9 | import cucumber.api.event.TestRunFinished;
|
11 | 10 | import cucumber.api.event.TestStepFinished;
|
12 | 11 | import cucumber.api.formatter.Formatter;
|
13 | 12 | import cucumber.api.formatter.NiceAppendable;
|
| 13 | +import cucumber.runtime.Utils; |
14 | 14 | import org.testng.ITestResult;
|
15 | 15 |
|
16 | 16 | class TestNgReporter implements Formatter {
|
@@ -50,19 +50,27 @@ void uri(String uri) {
|
50 | 50 |
|
51 | 51 | private void result(String stepText, Result result) {
|
52 | 52 | logResult(stepText, result);
|
53 |
| - |
54 |
| - if (result.is(Result.Type.FAILED) || result.is(Result.Type.AMBIGUOUS)) { |
55 |
| - ITestResult tr = getCurrentTestResult(); |
56 |
| - tr.setThrowable(result.getError()); |
57 |
| - tr.setStatus(ITestResult.FAILURE); |
58 |
| - } else if (result.is(Result.Type.SKIPPED)) { |
59 |
| - ITestResult tr = getCurrentTestResult(); |
60 |
| - tr.setThrowable(result.getError()); |
61 |
| - tr.setStatus(ITestResult.SKIP); |
62 |
| - } else if (result.is(Result.Type.UNDEFINED) || result.is(Result.Type.PENDING)) { |
63 |
| - ITestResult tr = getCurrentTestResult(); |
64 |
| - tr.setThrowable(result.getError()); |
65 |
| - tr.setStatus(ITestResult.FAILURE); |
| 53 | + ITestResult tr = getCurrentTestResult(); |
| 54 | + |
| 55 | + switch (result.getStatus()) { |
| 56 | + case PASSED: |
| 57 | + // do nothing |
| 58 | + break; |
| 59 | + case FAILED: |
| 60 | + case AMBIGUOUS: |
| 61 | + tr.setThrowable(result.getError()); |
| 62 | + tr.setStatus(ITestResult.FAILURE); |
| 63 | + break; |
| 64 | + case SKIPPED: |
| 65 | + tr.setThrowable(result.getError()); |
| 66 | + tr.setStatus(ITestResult.SKIP); |
| 67 | + case UNDEFINED: |
| 68 | + case PENDING: |
| 69 | + tr.setThrowable(result.getError()); |
| 70 | + tr.setStatus(ITestResult.FAILURE); |
| 71 | + break; |
| 72 | + default: |
| 73 | + throw new IllegalStateException("Unexpected result status: " + result.getStatus()); |
66 | 74 | }
|
67 | 75 | }
|
68 | 76 |
|
|
0 commit comments