Skip to content

Commit be545bf

Browse files
author
Philipp Loose
committed
Register new command for running parametrized tests
1 parent 34ebe55 commit be545bf

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/client/common/application/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu
9797
[Commands.Tests_Run]: [undefined | TestWorkspaceFolder, undefined | CommandSource, undefined | Uri, undefined | TestsToRun];
9898
// When command is invoked from a tree node, first argument is the node data.
9999
[Commands.Tests_Debug]: [undefined | TestWorkspaceFolder, undefined | CommandSource, undefined | Uri, undefined | TestsToRun];
100+
[Commands.Tests_Run_Parametrized]: [undefined, undefined | CommandSource, Uri, TestFunction[], boolean];
100101
// When command is invoked from a tree node, first argument is the node data.
101102
[Commands.Tests_Discover]: [undefined | TestWorkspaceFolder, undefined | CommandSource, undefined | Uri];
102103
[Commands.Tests_Run_Failed]: [undefined, CommandSource, Uri];

src/client/common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export namespace Commands {
3232
export const Tests_Run_Failed = 'python.runFailedTests';
3333
export const Sort_Imports = 'python.sortImports';
3434
export const Tests_Run = 'python.runtests';
35+
export const Tests_Run_Parametrized = 'python.runParametrizedTests';
3536
export const Tests_Debug = 'python.debugtests';
3637
export const Tests_Ask_To_Stop_Test = 'python.askToStopTests';
3738
export const Tests_Ask_To_Stop_Discovery = 'python.askToStopTestDiscovery';

src/client/testing/main.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,13 @@ export class UnitTestManagementService implements ITestManagementService, Dispos
225225
const testDisplay = this.serviceContainer.get<ITestDisplay>(ITestDisplay);
226226
testDisplay.displayFunctionTestPickerUI(cmdSource, testManager.workspaceFolder, testManager.workingDirectory, file, testFunctions, debug);
227227
}
228+
public async runParametrizedTests(cmdSource: CommandSource, resource: Uri, testFunctions: TestFunction[], debug?: boolean) {
229+
const testManager = await this.getTestManager(true, resource);
230+
if (!testManager) {
231+
return;
232+
}
233+
await this.runTestsImpl(cmdSource, resource, { testFunction: testFunctions }, undefined, debug);
234+
}
228235
public viewOutput(_cmdSource: CommandSource) {
229236
sendTelemetryEvent(EventName.UNITTEST_VIEW_OUTPUT);
230237
this.outputChannel.show();
@@ -398,6 +405,10 @@ export class UnitTestManagementService implements ITestManagementService, Dispos
398405
constants.Commands.Tests_Picker_UI_Debug,
399406
(_, cmdSource: CommandSource = CommandSource.commandPalette, file: Uri, testFunctions: TestFunction[]) => this.displayPickerUI(cmdSource, file, testFunctions, true)
400407
),
408+
commandManager.registerCommand(
409+
constants.Commands.Tests_Run_Parametrized,
410+
(_, cmdSource: CommandSource = CommandSource.commandPalette, resource: Uri, testFunctions: TestFunction[], debug: boolean) => this.runParametrizedTests(cmdSource, resource, testFunctions, debug)
411+
),
401412
commandManager.registerCommand(constants.Commands.Tests_Stop, (_, resource: Uri) => this.stopTests(resource)),
402413
commandManager.registerCommand(constants.Commands.Tests_ViewOutput, (_, cmdSource: CommandSource = CommandSource.commandPalette) => this.viewOutput(cmdSource)),
403414
commandManager.registerCommand(constants.Commands.Tests_Ask_To_Stop_Discovery, () => this.displayStopUI('Stop discovering tests')),

0 commit comments

Comments
 (0)