Skip to content

Commit

Permalink
show the messages
Browse files Browse the repository at this point in the history
  • Loading branch information
akshita31 committed May 25, 2018
1 parent 4be8950 commit 2c3f6c7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
12 changes: 9 additions & 3 deletions src/observers/DotnetTestLoggerObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/omnisharp/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ export namespace V2 {
Outcome: string;
ErrorMessage: string;
ErrorStackTrace: string;
StdOutMessages: string[];
}

export interface RunTestResponse {
Expand Down
24 changes: 16 additions & 8 deletions test/unitTests/logging/DotnetTestLoggerObserver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`, () => {
Expand All @@ -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
};
}

0 comments on commit 2c3f6c7

Please sign in to comment.