Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akshita31 committed May 24, 2018
1 parent 6d69083 commit a0eeb96
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/observers/DotnetTestLoggerObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class DotNetTestLoggerObserver extends BaseLoggerObserver {
}

private logTestResult(result: protocol.V2.DotNetTestResult) {
this.logger.appendLine(`${result.MethodName}: ${processOutcome(result.Outcome)}`);
this.logger.appendLine(`${result.MethodName}:`);
this.logger.increaseIndent();
this.logger.appendLine(`Outcome: ${processOutcome(result.Outcome)}`);
if (result.ErrorMessage) {
Expand All @@ -91,6 +91,6 @@ export default class DotNetTestLoggerObserver extends BaseLoggerObserver {
}
}

function processOutcome(input: string) {
export function processOutcome(input: string) {
return input.charAt(0).toUpperCase() + input.slice(1);
}
18 changes: 12 additions & 6 deletions test/unitTests/logging/DotnetTestLoggerObserver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { expect } from 'chai';
import * as chai from 'chai';
import { getNullChannel } from '../testAssets/Fakes';
import { EventWithMessage, DotNetTestDebugWarning, DotNetTestDebugStart, BaseEvent, DotNetTestRunStart, DotNetTestDebugProcessStart, DotNetTestMessage, DotNetTestDebugComplete, ReportDotNetTestResults } from '../../../src/omnisharp/loggingEvents';
import DotNetTestLoggerObserver from '../../../src/observers/DotnetTestLoggerObserver';
import * as protocol from '../../../src/omnisharp/protocol';

const expect = chai.expect;
chai.use(require('chai-string'));

suite(`${DotNetTestLoggerObserver.name}`, () => {
let appendedMessage: string;
let observer = new DotNetTestLoggerObserver({
Expand Down Expand Up @@ -65,16 +68,19 @@ suite(`${DotNetTestLoggerObserver.name}`, () => {
test(`Displays the outcome of each test`, () => {
observer.post(event);
event.results.forEach(result => {
expect(appendedMessage).to.contain(`${result.MethodName}: ${result.Outcome}`);
expect(appendedMessage).to.containIgnoreCase(`${result.MethodName}:\n Outcome: ${result.Outcome}`);
});
});

test(`Displays the total outcome`, () => {
observer.post(event);
expect(appendedMessage).to.contain(`Total tests: ${event.results.length}. Passed: 1. Failed: 2. Skipped: 1`);
event.results.forEach(result => {
expect(appendedMessage).to.contain(`${result.MethodName}: ${result.Outcome}`);
});
expect(appendedMessage).to.contain(`Total tests: 4. Passed: 1. Failed: 2. Skipped: 1`);
});

test('Displays the error message if any is present', () => {
observer.post(event);
expect(appendedMessage).to.contain("foo:\n Outcome: Failed\n Error Message: assertion failed");
expect(appendedMessage).to.contain("failinator:\n Outcome: Failed\n Error Message: error occured");
});
});
});
Expand Down

0 comments on commit a0eeb96

Please sign in to comment.