Skip to content

Commit

Permalink
add exception to test-case-finished event (#952)
Browse files Browse the repository at this point in the history
  • Loading branch information
gd46 authored and charlierudolph committed Nov 5, 2017
1 parent 052cd20 commit 184faba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion features/fixtures/event_protocol_formatter/failed.ndjson
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
{"type":"test-case-started","sourceLocation":{"uri":"features/a.feature","line":2}}
{"type":"test-step-started","index":0,"testCase":{"sourceLocation":{"uri":"features/a.feature","line":2}}}
{"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}}}
{"type":"test-case-finished","result":{"duration":0,"status":"failed"},"sourceLocation":{"uri":"features/a.feature","line":2}}
{"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}}
{"type":"test-run-finished","result":{"duration":0,"success":false}}
3 changes: 3 additions & 0 deletions src/runtime/test_case_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ export default class TestCaseRunner {
if (this.shouldUpdateStatus(testStepResult)) {
this.result.status = testStepResult.status
}
if (testStepResult.exception) {
this.result.exception = testStepResult.exception
}
this.emit('test-step-finished', {
index: this.testStepIndex,
result: testStepResult
Expand Down
12 changes: 10 additions & 2 deletions src/runtime/test_case_runner_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ describe('TestCaseRunner', function() {
expect(this.onTestCaseFinished).to.have.been.calledWith({
result: {
duration: 1,
status: Status.FAILED
status: Status.FAILED,
exception: this.error
},
sourceLocation: { line: 1, uri: 'path/to/feature' }
})
Expand Down Expand Up @@ -298,7 +299,14 @@ describe('TestCaseRunner', function() {
it('emits test-case-finished', function() {
expect(this.onTestCaseFinished).to.have.been.calledOnce
expect(this.onTestCaseFinished).to.have.been.calledWith({
result: { duration: 0, status: Status.AMBIGUOUS },
result: {
duration: 0,
status: Status.AMBIGUOUS,
exception:
'Multiple step definitions match:\n' +
' pattern1 - path/to/steps:3\n' +
' pattern2 - path/to/steps:4'
},
sourceLocation: { line: 1, uri: 'path/to/feature' }
})
})
Expand Down

0 comments on commit 184faba

Please sign in to comment.