From 8d92744b4f333a1ae1bbea28bf80626140b4fc09 Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Wed, 31 May 2023 09:44:36 +0800 Subject: [PATCH] fix: Cannot run tests from Java Projects view (#1575) Signed-off-by: Sheng Chen --- package.json | 6 +++--- src/commands/projectExplorerCommands.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 7b0006d1..72aa9c11 100644 --- a/package.json +++ b/package.json @@ -89,17 +89,17 @@ "view/item/context": [ { "command": "java.test.runFromJavaProjectExplorer", - "when": "view == javaProjectExplorer && viewItem =~ /java:(type|package|packageRoot)(?=.*?\\b\\+uri\\b)(?=.*?\\b\\+source\\b)(?=.*?\\b\\+test\\b)/", + "when": "view == javaProjectExplorer && viewItem =~ /java:(type|package|packageRoot)(?=.*?\\b\\+uri\\b)(?=.*?\\b\\+test\\b)(?!.*?\\b\\+resource\\b)/", "group": "8_execution@10" }, { "command": "java.test.debugFromJavaProjectExplorer", - "when": "view == javaProjectExplorer && viewItem =~ /java:(type|package|packageRoot)(?=.*?\\b\\+uri\\b)(?=.*?\\b\\+source\\b)(?=.*?\\b\\+test\\b)/", + "when": "view == javaProjectExplorer && viewItem =~ /java:(type|package|packageRoot)(?=.*?\\b\\+uri\\b)(?=.*?\\b\\+test\\b)(?!.*?\\b\\+resource\\b)/", "group": "8_execution@20" }, { "command": "java.test.runFromJavaProjectExplorer", - "when": "view == javaProjectExplorer && viewItem =~ /java:(type|package|packageRoot)(?=.*?\\b\\+uri\\b)(?=.*?\\b\\+source\\b)(?=.*?\\b\\+test\\b)/", + "when": "view == javaProjectExplorer && viewItem =~ /java:(type|package|packageRoot)(?=.*?\\b\\+uri\\b)(?=.*?\\b\\+test\\b)(?!.*?\\b\\+resource\\b)/", "group": "inline@run_0" } ], diff --git a/src/commands/projectExplorerCommands.ts b/src/commands/projectExplorerCommands.ts index 886fd1e0..192daa3b 100644 --- a/src/commands/projectExplorerCommands.ts +++ b/src/commands/projectExplorerCommands.ts @@ -32,7 +32,7 @@ export async function runTestsFromJavaProjectExplorer(node: any, isDebug: boolea const nodeFsPath: string = Uri.parse(node._nodeData.uri).fsPath; projectItem.children.forEach((child: TestItem) => { const itemPath: string = child.uri?.fsPath || ''; - if (isHierarchicalMode || node._nodeData.kind === 4 /*packageRoot*/) { + if (isHierarchicalMode || node._nodeData.kind === 3 /*packageRoot*/) { // if the selected node is a package root or the view is in hierarchical mode, // all the test items whose path start from the path of the selected node will be added if (itemPath.startsWith(nodeFsPath)) { @@ -55,7 +55,7 @@ export async function runTestsFromJavaProjectExplorer(node: any, isDebug: boolea function getTestLevel(nodeData: any): TestLevel { // The command will only register on the class/package/packageRoot // nodes of the Java Project explorer - if (nodeData.kind === 6 /*PrimaryType*/) { + if (nodeData.kind === 5 /*PrimaryType*/) { return TestLevel.Class; } else { return TestLevel.Package;