diff --git a/src/observers/DotnetTestLoggerObserver.ts b/src/observers/DotnetTestLoggerObserver.ts index fb40e576e..f34beab8c 100644 --- a/src/observers/DotnetTestLoggerObserver.ts +++ b/src/observers/DotnetTestLoggerObserver.ts @@ -84,12 +84,23 @@ export default class DotNetTestLoggerObserver extends BaseLoggerObserver { this.logger.increaseIndent(); this.logger.appendLine(`Outcome: ${processOutcome(result.Outcome)}`); if (result.ErrorMessage) { - this.logger.appendLine(`Error Message: ${result.ErrorMessage}`); - + this.logger.appendLine(`Error Message:`); + this.logger.appendLine(result.ErrorMessage); } if (result.ErrorStackTrace) { - this.logger.appendLine(`Stack Trace: ${result.ErrorStackTrace}`); + this.logger.appendLine(`Stack Trace:`); + this.logger.appendLine(result.ErrorStackTrace); + } + + if (result.StandardOutput && result.StandardOutput.length > 0) { + this.logger.appendLine("Standard Output Messages:"); + result.StandardOutput.forEach(message => this.logger.appendLine(message)); + } + + if (result.StandardError && result.StandardError.length > 0) { + this.logger.appendLine("Standard Error Messages:"); + result.StandardError.forEach(message => this.logger.appendLine(message)); } this.logger.appendLine(); diff --git a/src/omnisharp/protocol.ts b/src/omnisharp/protocol.ts index 4cd44950e..b481a1817 100644 --- a/src/omnisharp/protocol.ts +++ b/src/omnisharp/protocol.ts @@ -609,6 +609,8 @@ export namespace V2 { Outcome: string; ErrorMessage: string; ErrorStackTrace: string; + StandardOutput: string[]; + StandardError: string[]; } export interface RunTestResponse { diff --git a/test/unitTests/logging/DotnetTestLoggerObserver.test.ts b/test/unitTests/logging/DotnetTestLoggerObserver.test.ts index 4f3b1fb0b..1931dc2c2 100644 --- a/test/unitTests/logging/DotnetTestLoggerObserver.test.ts +++ b/test/unitTests/logging/DotnetTestLoggerObserver.test.ts @@ -59,10 +59,10 @@ suite(`${DotNetTestLoggerObserver.name}`, () => { suite(`${ReportDotNetTestResults.name}`, () => { let event = new ReportDotNetTestResults( [ - getDotNetTestResults("foo", "failed", "assertion failed", "stacktrace1"), - getDotNetTestResults("failinator", "failed", "error occured", "stacktrace2"), - getDotNetTestResults("bar", "skipped", "", ""), - getDotNetTestResults("passinator", "passed", "", ""), + getDotNetTestResults("foo", "failed", "assertion failed", "stacktrace1" , ["message1", "message2"], ["errorMessage1"]), + getDotNetTestResults("failinator", "failed", "error occured", "stacktrace2", [], []), + getDotNetTestResults("bar", "skipped", "", "", ["message3", "message4"], []), + getDotNetTestResults("passinator", "passed", "", "", [], []), ]); test(`Displays the outcome of each test`, () => { @@ -79,17 +79,33 @@ suite(`${DotNetTestLoggerObserver.name}`, () => { test('Displays the error message and error stack trace if any is present', () => { observer.post(event); - expect(appendedMessage).to.contain("foo:\n Outcome: Failed\n Error Message: assertion failed\n Stack Trace: stacktrace1"); - expect(appendedMessage).to.contain("failinator:\n Outcome: Failed\n Error Message: error occured\n Stack Trace: stacktrace2"); + expect(appendedMessage).to.contain("foo:\n Outcome: Failed\n Error Message:\n assertion failed\n Stack Trace:\n stacktrace1"); + expect(appendedMessage).to.contain("failinator:\n Outcome: Failed\n Error Message:\n error occured\n Stack Trace:\n stacktrace2"); + }); + + test(`Displays the standard output messages if any`, () => { + observer.post(event); + event.results.forEach(result => { + result.StandardOutput.forEach(message => expect(appendedMessage).to.contain(message)); + }); + }); + + test(`Displays the standard error messages if any`, () => { + observer.post(event); + event.results.forEach(result => { + result.StandardError.forEach(message => expect(appendedMessage).to.contain(message)); + }); }); }); }); -function getDotNetTestResults(methodname: string, outcome: string, errorMessage: string, errorStackTrace: string): protocol.V2.DotNetTestResult { +function getDotNetTestResults(methodname: string, outcome: string, errorMessage: string, errorStackTrace: string, stdoutMessages: string[], stdErrorMessages: string[]): protocol.V2.DotNetTestResult { return { MethodName: methodname, Outcome: outcome, ErrorMessage: errorMessage, - ErrorStackTrace: errorStackTrace + ErrorStackTrace: errorStackTrace, + StandardOutput : stdoutMessages, + StandardError: stdErrorMessages }; } \ No newline at end of file