mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
publish test coverage at the right time in the test sample (#924)
This commit is contained in:
@ -102,25 +102,25 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
run.appendOutput(`Completed ${test.id}\r\n`);
|
||||
}
|
||||
|
||||
run.coverageProvider = {
|
||||
provideFileCoverage() {
|
||||
const coverage: vscode.FileCoverage[] = [];
|
||||
for (const [uri, statements] of coveredLines) {
|
||||
coverage.push(
|
||||
vscode.FileCoverage.fromDetails(
|
||||
vscode.Uri.parse(uri),
|
||||
statements.filter((s): s is vscode.StatementCoverage => !!s)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return coverage;
|
||||
},
|
||||
};
|
||||
|
||||
run.end();
|
||||
};
|
||||
|
||||
run.coverageProvider = {
|
||||
provideFileCoverage() {
|
||||
const coverage: vscode.FileCoverage[] = [];
|
||||
for (const [uri, statements] of coveredLines) {
|
||||
coverage.push(
|
||||
vscode.FileCoverage.fromDetails(
|
||||
vscode.Uri.parse(uri),
|
||||
statements.filter((s): s is vscode.StatementCoverage => !!s)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return coverage;
|
||||
},
|
||||
};
|
||||
|
||||
discoverTests(request.include ?? gatherTestItems(ctrl.items)).then(runTestQueue);
|
||||
};
|
||||
|
||||
|
||||
@ -175,6 +175,11 @@ declare module 'vscode' {
|
||||
* Contains coverage information for a function or method.
|
||||
*/
|
||||
export class FunctionCoverage {
|
||||
/**
|
||||
* Name of the function or method.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The number of times this function was executed. If zero, the
|
||||
* function will be marked as un-covered.
|
||||
@ -190,7 +195,7 @@ declare module 'vscode' {
|
||||
* @param executionCount The number of times this function was executed.
|
||||
* @param location The function position.
|
||||
*/
|
||||
constructor(executionCount: number, location: Position | Range);
|
||||
constructor(name: string, executionCount: number, location: Position | Range);
|
||||
}
|
||||
|
||||
export type DetailedCoverage = StatementCoverage | FunctionCoverage;
|
||||
|
||||
Reference in New Issue
Block a user