From 2c3f6c7d700f8ebb6ee92988d9add84aa890cd8a Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Thu, 24 May 2018 17:10:34 -0700 Subject: [PATCH] show the messages --- src/observers/DotnetTestLoggerObserver.ts | 12 +++++++--- src/omnisharp/protocol.ts | 1 + .../logging/DotnetTestLoggerObserver.test.ts | 24 ++++++++++++------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/observers/DotnetTestLoggerObserver.ts b/src/observers/DotnetTestLoggerObserver.ts index fb40e576ed..2848a0f3ef 100644 --- a/src/observers/DotnetTestLoggerObserver.ts +++ b/src/observers/DotnetTestLoggerObserver.ts @@ -84,12 +84,18 @@ 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.StdOutMessages && result.StdOutMessages.length > 0) { + this.logger.appendLine("Standard Output Messages:"); + result.StdOutMessages.forEach(message => this.logger.appendLine(message)); } this.logger.appendLine(); diff --git a/src/omnisharp/protocol.ts b/src/omnisharp/protocol.ts index 4cd44950e5..92810f835e 100644 --- a/src/omnisharp/protocol.ts +++ b/src/omnisharp/protocol.ts @@ -609,6 +609,7 @@ export namespace V2 { Outcome: string; ErrorMessage: string; ErrorStackTrace: string; + StdOutMessages: string[]; } export interface RunTestResponse { diff --git a/test/unitTests/logging/DotnetTestLoggerObserver.test.ts b/test/unitTests/logging/DotnetTestLoggerObserver.test.ts index 4f3b1fb0bd..4dd5f32d32 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"]), + getDotNetTestResults("failinator", "failed", "error occured", "stacktrace2", []), + getDotNetTestResults("bar", "skipped", "", "", ["message3", "message4"]), + getDotNetTestResults("passinator", "passed", "", "", []), ]); test(`Displays the outcome of each test`, () => { @@ -79,17 +79,25 @@ 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 Stdout messages if any`, () => { + observer.post(event); + event.results.forEach(result => { + result.StdOutMessages.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[]): protocol.V2.DotNetTestResult { return { MethodName: methodname, Outcome: outcome, ErrorMessage: errorMessage, - ErrorStackTrace: errorStackTrace + ErrorStackTrace: errorStackTrace, + StdOutMessages : stdoutMessages }; } \ No newline at end of file