Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show the standard output messages #2343

Merged
merged 1 commit into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/observers/DotnetTestLoggerObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/omnisharp/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,8 @@ export namespace V2 {
Outcome: string;
ErrorMessage: string;
ErrorStackTrace: string;
StandardOutput: string[];
StandardError: string[];
}

export interface RunTestResponse {
Expand Down
32 changes: 24 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"], ["errorMessage1"]),
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,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
};
}