Skip to content

Commit 8c0e889

Browse files
committed
feat(vscode): support for creating test profiles in vscodes test explorer
In `launch.json` you can create a new entry with purpose `test-profile` this entry is show in the "run tests" and "debug tests" drop down and can be selected by right click on a test end then "Execute Using Profile..." entry. This profile is then used instead of the default test launch config with the purpose `test` Example ```jsonc { "name": "Test Environment", "type": "robotcode", "purpose": "test-profile", "request": "launch", "presentation": { "hidden": true }, "variables": { "TEST_PROFILE_VAR": "TEST_PROFILE_VALUE" } } ```
1 parent 5631a1b commit 8c0e889

File tree

3 files changed

+181
-80
lines changed

3 files changed

+181
-80
lines changed

package.json

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,22 +1130,26 @@
11301130
],
11311131
"enum": [
11321132
"default",
1133-
"test"
1133+
"test",
1134+
"test-profile"
11341135
],
1135-
"enumDescriptions": [
1136-
"Use this configuration as default for all other configurations.",
1137-
"Use this configuration when running or debugging tests."
1136+
"markdownEnumDescriptions": [
1137+
"Configuration is uses as default for all other configurations.",
1138+
"Default configuration for running or debugging tests.",
1139+
"Defines a test profile that you can select in the test explorer or via the play button during a test. This configuration is used instead of the configuration with the purpose `test`."
11381140
],
11391141
"default": [],
11401142
"description": "Defines what purpose this configuration has.",
11411143
"items": {
11421144
"enum": [
11431145
"default",
1144-
"test"
1146+
"test",
1147+
"test-profile"
11451148
],
1146-
"enumDescriptions": [
1147-
"Use this configuration as default for all other configurations.",
1148-
"Use this configuration when running or debugging tests."
1149+
"markdownEnumDescriptions": [
1150+
"Configuration is uses as default for all other configurations.",
1151+
"Default configuration for running or debugging tests.",
1152+
"Defines a test profile that you can select in the test explorer or via the play button during a test. This configuration is used instead of the configuration with the purpose `test`."
11491153
]
11501154
}
11511155
},
@@ -1239,6 +1243,19 @@
12391243
"purpose": "test"
12401244
}
12411245
},
1246+
{
1247+
"label": "RobotCode: Test Profile",
1248+
"description": "Create a new test profile that is displayed in the test explorer.",
1249+
"body": {
1250+
"name": "RobotCode: Test Profile",
1251+
"type": "robotcode",
1252+
"request": "launch",
1253+
"presentation": {
1254+
"hidden": true
1255+
},
1256+
"purpose": "test-profile"
1257+
}
1258+
},
12421259
{
12431260
"label": "RobotCode: Default",
12441261
"description": "Default configuration.",

vscode-client/debugmanager.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,9 @@ export class DebugManager {
470470
excluded: string[],
471471
runId?: string,
472472
options?: vscode.DebugSessionOptions,
473-
dryRun?: boolean,
474473
topLevelSuiteName?: string,
474+
profiles?: string[],
475+
testConfiguration?: { [Key: string]: unknown },
475476
): Promise<boolean> {
476477
const config = vscode.workspace.getConfiguration(CONFIG_SECTION, folder);
477478

@@ -509,14 +510,16 @@ export class DebugManager {
509510
}
510511

511512
const testLaunchConfig: { [Key: string]: unknown } =
513+
testConfiguration ??
512514
vscode.workspace
513515
.getConfiguration("launch", folder)
514516
?.get<{ [Key: string]: unknown }[]>("configurations")
515517
?.find(
516518
(v) =>
517519
v?.type === "robotcode" &&
518520
(v?.purpose === "test" || (Array.isArray(v?.purpose) && v?.purpose?.indexOf("test") > -1)),
519-
) ?? {};
521+
) ??
522+
{};
520523

521524
if (!("target" in testLaunchConfig)) {
522525
testLaunchConfig.target = "";
@@ -525,13 +528,15 @@ export class DebugManager {
525528
let paths = config.get<string[]>("robot.paths", []);
526529
paths = "paths" in testLaunchConfig ? [...(testLaunchConfig.paths as string[]), ...paths] : paths;
527530

531+
if (profiles) testLaunchConfig.profiles = profiles;
532+
528533
return vscode.debug.startDebugging(
529534
folder,
530535
{
531536
...testLaunchConfig,
532537
...{
533538
type: "robotcode",
534-
name: `RobotCode: Run Tests ${folder.name}`,
539+
name: (testLaunchConfig?.name as string) ?? `RobotCode: Run Tests ${folder.name}`,
535540
request: "launch",
536541
cwd: folder?.uri.fsPath,
537542
paths: paths?.length > 0 ? paths : ["."],
@@ -541,7 +546,6 @@ export class DebugManager {
541546
? testLaunchConfig.console
542547
: config.get("debug.defaultConsole", "integratedTerminal"),
543548
runId: runId,
544-
dryRun,
545549
},
546550
},
547551
options,

0 commit comments

Comments
 (0)