Skip to content

Commit

Permalink
Merge pull request #2579 from rchande/handleEmptyTests
Browse files Browse the repository at this point in the history
Handle empty tests
  • Loading branch information
Ravi Chande authored Oct 4, 2018
2 parents 9fc3ad8 + da7b8e5 commit 030ec63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/observers/DotnetTestLoggerObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export default class DotNetTestLoggerObserver extends BaseLoggerObserver {
private handleReportDotnetTestResults(event: ReportDotNetTestResults) {
this.logger.appendLine("----- Test Execution Summary -----");
this.logger.appendLine('');
const results = event.results;

// Omnisharp returns null results if there are build failures
const results = event.results || [];
const totalTests = results.length;

let totalPassed = 0, totalFailed = 0, totalSkipped = 0;
Expand Down
5 changes: 5 additions & 0 deletions test/unitTests/logging/DotnetTestLoggerObserver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ suite(`${DotNetTestLoggerObserver.name}`, () => {
result.StandardError.forEach(message => expect(appendedMessage).to.contain(message));
});
});

test(`Can handle malformed results`, () => {
observer.post(new ReportDotNetTestResults([]));
expect(appendedMessage).to.contain("----- Test Execution Summary -----\n\nTotal tests: 0. Passed: 0. Failed: 0. Skipped: 0");
});
});
});

Expand Down

0 comments on commit 030ec63

Please sign in to comment.