Skip to content

Commit 184faba

Browse files
gd46charlierudolph
authored andcommitted
add exception to test-case-finished event (#952)
1 parent 052cd20 commit 184faba

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

features/fixtures/event_protocol_formatter/failed.ndjson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
{"type":"test-case-started","sourceLocation":{"uri":"features/a.feature","line":2}}
88
{"type":"test-step-started","index":0,"testCase":{"sourceLocation":{"uri":"features/a.feature","line":2}}}
99
{"type":"test-step-finished","index":0,"result":{"duration":0,"exception":"Error: my error\n at World.<anonymous> (features/step_definitions/steps.js:4:51)","status":"failed"},"testCase":{"sourceLocation":{"uri":"features/a.feature","line":2}}}
10-
{"type":"test-case-finished","result":{"duration":0,"status":"failed"},"sourceLocation":{"uri":"features/a.feature","line":2}}
10+
{"type":"test-case-finished","result":{"duration":0,"status":"failed","exception":"Error: my error\n at World.<anonymous> (features/step_definitions/steps.js:4:51)"},"sourceLocation":{"uri":"features/a.feature","line":2}}
1111
{"type":"test-run-finished","result":{"duration":0,"success":false}}

src/runtime/test_case_runner.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ export default class TestCaseRunner {
143143
if (this.shouldUpdateStatus(testStepResult)) {
144144
this.result.status = testStepResult.status
145145
}
146+
if (testStepResult.exception) {
147+
this.result.exception = testStepResult.exception
148+
}
146149
this.emit('test-step-finished', {
147150
index: this.testStepIndex,
148151
result: testStepResult

src/runtime/test_case_runner_spec.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ describe('TestCaseRunner', function() {
217217
expect(this.onTestCaseFinished).to.have.been.calledWith({
218218
result: {
219219
duration: 1,
220-
status: Status.FAILED
220+
status: Status.FAILED,
221+
exception: this.error
221222
},
222223
sourceLocation: { line: 1, uri: 'path/to/feature' }
223224
})
@@ -298,7 +299,14 @@ describe('TestCaseRunner', function() {
298299
it('emits test-case-finished', function() {
299300
expect(this.onTestCaseFinished).to.have.been.calledOnce
300301
expect(this.onTestCaseFinished).to.have.been.calledWith({
301-
result: { duration: 0, status: Status.AMBIGUOUS },
302+
result: {
303+
duration: 0,
304+
status: Status.AMBIGUOUS,
305+
exception:
306+
'Multiple step definitions match:\n' +
307+
' pattern1 - path/to/steps:3\n' +
308+
' pattern2 - path/to/steps:4'
309+
},
302310
sourceLocation: { line: 1, uri: 'path/to/feature' }
303311
})
304312
})

0 commit comments

Comments
 (0)