Skip to content

Commit e1d0ad5

Browse files
author
Philipp Loose
committed
Show "Run All" or "Debug All" in dropdown picker on parametrized tests
1 parent be545bf commit e1d0ad5

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/client/testing/display/picker.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ export class TestDisplay implements ITestDisplay {
6565
return fn.parentTestFile.name === testFile.name &&
6666
testFunctions.some(testFunc => testFunc.nameToRun === fn.testFunction.nameToRun);
6767
});
68-
69-
this.appShell.showQuickPick(buildItemsForFunctions(rootDirectory, flattenedFunctions, undefined, undefined, debug),
70-
{ matchOnDescription: true, matchOnDetail: true })
68+
const runAllItem = buildRunAllParametrizedItem(flattenedFunctions, debug);
69+
const functionItems = buildItemsForFunctions(rootDirectory, flattenedFunctions, undefined, undefined, debug);
70+
this.appShell.showQuickPick(runAllItem.concat(...functionItems), { matchOnDescription: true, matchOnDetail: true })
7171
.then(testItem => testItem ? onItemSelected(this.commandManager, cmdSource, wkspace, testItem, debug) : Promise.resolve());
7272
}
7373
}
@@ -84,7 +84,8 @@ export enum Type {
8484
Null = 8,
8585
SelectAndRunMethod = 9,
8686
DebugMethod = 10,
87-
Configure = 11
87+
Configure = 11,
88+
RunParametrized = 12
8889
}
8990
const statusIconMapping = new Map<TestStatus, string>();
9091
statusIconMapping.set(TestStatus.Pass, constants.Octicons.Test_Pass);
@@ -95,6 +96,7 @@ statusIconMapping.set(TestStatus.Skipped, constants.Octicons.Test_Skip);
9596
type TestItem = QuickPickItem & {
9697
type: Type;
9798
fn?: FlattenedTestFunction;
99+
fns?: TestFunction[];
98100
};
99101

100102
type TestFileItem = QuickPickItem & {
@@ -150,6 +152,18 @@ const statusSortPrefix = {
150152
[TestStatus.Unknown]: undefined
151153
};
152154

155+
function buildRunAllParametrizedItem(tests: FlattenedTestFunction[], debug: boolean = false): TestItem[] {
156+
const testFunctions: TestFunction[] = [];
157+
tests.forEach(fn => {
158+
testFunctions.push(fn.testFunction);
159+
});
160+
return [{
161+
description: '',
162+
label: debug ? 'Debug All' : 'Run All',
163+
type: Type.RunParametrized,
164+
fns: testFunctions
165+
}];
166+
}
153167
function buildItemsForFunctions(rootDirectory: string, tests: FlattenedTestFunction[], sortBasedOnResults: boolean = false, displayStatusIcons: boolean = false, debug: boolean = false): TestItem[] {
154168
const functionItems: TestItem[] = [];
155169
tests.forEach(fn => {
@@ -218,6 +232,9 @@ export function onItemSelected(commandManager: ICommandManager, cmdSource: Comma
218232
case Type.RunAll: {
219233
return commandManager.executeCommand(constants.Commands.Tests_Run, undefined, cmdSource, wkspace, undefined);
220234
}
235+
case Type.RunParametrized: {
236+
return commandManager.executeCommand(constants.Commands.Tests_Run_Parametrized, undefined, cmdSource, wkspace, selection.fns!, debug!);
237+
}
221238
case Type.ReDiscover: {
222239
return commandManager.executeCommand(constants.Commands.Tests_Discover, undefined, cmdSource, wkspace);
223240
}

0 commit comments

Comments
 (0)