Skip to content
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"displayName": "PHPUnit Test Explorer",
"icon": "img/icon.png",
"publisher": "recca0120",
"version": "3.7.2",
"version": "3.7.3",
"private": true,
"license": "MIT",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions src/Observers/OutputChannelObserver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('OutputChannelObserver', () => {
await run(testFile);

const outputChannel = getOutputChannel();
expect(outputChannel.appendLine).toHaveBeenCalledWith(
expect(outputChannel.append).toHaveBeenCalledWith(
expect.stringMatching(/Tests: \d+, Assertions: \d+/),
);
});
Expand All @@ -225,7 +225,7 @@ describe('OutputChannelObserver', () => {
await run(testFile);

const outputChannel = getOutputChannel();
expect(outputChannel.appendLine).toHaveBeenCalledWith(
expect(outputChannel.append).toHaveBeenCalledWith(
expect.stringMatching(/Time: [\d:.]+(\s\w+)?, Memory: [\d.]+\s\w+/),
);
});
Expand Down
22 changes: 15 additions & 7 deletions src/Observers/OutputChannelObserver.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { OutputChannel, TestRunRequest } from 'vscode';
import {
Builder, IConfiguration, TestConfiguration, TestDuration, TestFailed, TestFinished, TestIgnored,
TestProcesses, TestResult, TestResultSummary, TestRunnerObserver, TestRuntime, TestStarted, TestSuiteFinished,
TestSuiteStarted, TestVersion,
Builder, IConfiguration, TestConfiguration, TestDuration, TestFailed, TestFinished, TestIgnored, TestProcesses,
TestResult, TestResultSummary, TestRunnerObserver, TestRuntime, TestStarted, TestSuiteFinished, TestSuiteStarted,
TestVersion,
} from '../PHPUnit';
import { Printer } from './Printers';

Expand Down Expand Up @@ -91,16 +91,18 @@ export class OutputChannelObserver implements TestRunnerObserver {
this.appendLine(this.printer.testSuiteFinished(result));
}

testDuration(result: TestDuration) {
testResultSummary(result: TestResultSummary) {
this.appendLine(this.printer.end());
this.appendLine(this.printer.timeAndMemory(result));
this.append(this.printer.testResultSummary(result));
}

testResultSummary(result: TestResultSummary) {
this.appendLine(this.printer.testResultSummary(result));
testDuration(result: TestDuration) {
this.appendLine(this.printer.end());
this.append(this.printer.timeAndMemory(result));
}

close() {
this.appendLine(this.printer.end());
this.printedOutput();
this.printer.close();
}
Expand All @@ -113,6 +115,12 @@ export class OutputChannelObserver implements TestRunnerObserver {
}
}

private append(text: string | undefined) {
if (text !== undefined) {
this.outputChannel.append(text);
}
}

private appendLine(text: string | undefined) {
if (text !== undefined) {
this.outputChannel.appendLine(text);
Expand Down
6 changes: 4 additions & 2 deletions src/Observers/Printers/CollisionPrinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Printer } from './Printer';
export class CollisionPrinter extends Printer {
private errors: TestFailed[] = [];


start() {
super.start();
this.errors = [];
Expand All @@ -31,7 +30,10 @@ export class CollisionPrinter extends Printer {
}

end() {
return this.errors.map((result) => this.formatError(result)).join(EOL);
const error = this.errors.map((result) => this.formatError(result)).join(EOL);
this.errors = [];

return error;
}

private formatError(result: TestFailed) {
Expand Down
4 changes: 2 additions & 2 deletions src/Observers/Printers/Printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ export abstract class Printer {
timeAndMemory(result: TestDuration) {
this.setCurrent(undefined);

return result.text;
return result.text.trim();
}

testResultSummary(result: TestResultSummary) {
this.setCurrent(undefined);

return result.text;
return result.text.trim();
}

end(): string | undefined {
Expand Down