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

Add "Run All" CodeLens for parametrized tests #8682

Closed
Closed
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
1 change: 1 addition & 0 deletions src/client/common/application/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu
[Commands.Tests_Run]: [undefined | TestWorkspaceFolder, undefined | CommandSource, undefined | Uri, undefined | TestsToRun];
// When command is invoked from a tree node, first argument is the node data.
[Commands.Tests_Debug]: [undefined | TestWorkspaceFolder, undefined | CommandSource, undefined | Uri, undefined | TestsToRun];
[Commands.Tests_Run_Parametrized]: [undefined, undefined | CommandSource, Uri, TestFunction[]];
// When command is invoked from a tree node, first argument is the node data.
[Commands.Tests_Discover]: [undefined | TestWorkspaceFolder, undefined | CommandSource, undefined | Uri];
[Commands.Tests_Run_Failed]: [undefined, CommandSource, Uri];
Expand Down
1 change: 1 addition & 0 deletions src/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export namespace Commands {
export const Tests_Run_Failed = 'python.runFailedTests';
export const Sort_Imports = 'python.sortImports';
export const Tests_Run = 'python.runtests';
export const Tests_Run_Parametrized = 'python.runParametrizedTests';
export const Tests_Debug = 'python.debugtests';
export const Tests_Ask_To_Stop_Test = 'python.askToStopTests';
export const Tests_Ask_To_Stop_Discovery = 'python.askToStopTestDiscovery';
Expand Down
5 changes: 5 additions & 0 deletions src/client/testing/codeLenses/testFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ function getFunctionCodeLens(file: Uri, functionsAndSuites: FunctionsAndSuites,
title: `${getTestStatusIcons(functions)}${constants.Text.CodeLensDebugUnitTest} (Multiple)`,
command: constants.Commands.Tests_Picker_UI_Debug,
arguments: [undefined, CommandSource.codelens, file, functions]
}),
new CodeLens(range, {
title: `${getTestStatusIcons(functions)}Run All`,
command: constants.Commands.Tests_Run_Parametrized,
arguments: [undefined, CommandSource.codelens, file, functions]
})
];
}
Expand Down
11 changes: 11 additions & 0 deletions src/client/testing/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ export class UnitTestManagementService implements ITestManagementService, Dispos
const testDisplay = this.serviceContainer.get<ITestDisplay>(ITestDisplay);
testDisplay.displayFunctionTestPickerUI(cmdSource, testManager.workspaceFolder, testManager.workingDirectory, file, testFunctions, debug);
}
public async runParametrizedTests(cmdSource: CommandSource, file: Uri, testFunctions: TestFunction[]) {
const testManager = await this.getTestManager(true, file);
if (!testManager) {
return;
}
await this.runTestsImpl(cmdSource, file, { testFunction: testFunctions });
}
public viewOutput(_cmdSource: CommandSource) {
sendTelemetryEvent(EventName.UNITTEST_VIEW_OUTPUT);
this.outputChannel.show();
Expand Down Expand Up @@ -398,6 +405,10 @@ export class UnitTestManagementService implements ITestManagementService, Dispos
constants.Commands.Tests_Picker_UI_Debug,
(_, cmdSource: CommandSource = CommandSource.commandPalette, file: Uri, testFunctions: TestFunction[]) => this.displayPickerUI(cmdSource, file, testFunctions, true)
),
commandManager.registerCommand(
constants.Commands.Tests_Run_Parametrized,
(_, cmdSource: CommandSource = CommandSource.commandPalette, file: Uri, testFunctions: TestFunction[]) => this.runParametrizedTests(cmdSource, file, testFunctions)
),
commandManager.registerCommand(constants.Commands.Tests_Stop, (_, resource: Uri) => this.stopTests(resource)),
commandManager.registerCommand(constants.Commands.Tests_ViewOutput, (_, cmdSource: CommandSource = CommandSource.commandPalette) => this.viewOutput(cmdSource)),
commandManager.registerCommand(constants.Commands.Tests_Ask_To_Stop_Discovery, () => this.displayStopUI('Stop discovering tests')),
Expand Down