Skip to content

Commit 8d92744

Browse files
authored
fix: Cannot run tests from Java Projects view (#1575)
Signed-off-by: Sheng Chen <[email protected]>
1 parent 394f15f commit 8d92744

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,17 @@
8989
"view/item/context": [
9090
{
9191
"command": "java.test.runFromJavaProjectExplorer",
92-
"when": "view == javaProjectExplorer && viewItem =~ /java:(type|package|packageRoot)(?=.*?\\b\\+uri\\b)(?=.*?\\b\\+source\\b)(?=.*?\\b\\+test\\b)/",
92+
"when": "view == javaProjectExplorer && viewItem =~ /java:(type|package|packageRoot)(?=.*?\\b\\+uri\\b)(?=.*?\\b\\+test\\b)(?!.*?\\b\\+resource\\b)/",
9393
"group": "8_execution@10"
9494
},
9595
{
9696
"command": "java.test.debugFromJavaProjectExplorer",
97-
"when": "view == javaProjectExplorer && viewItem =~ /java:(type|package|packageRoot)(?=.*?\\b\\+uri\\b)(?=.*?\\b\\+source\\b)(?=.*?\\b\\+test\\b)/",
97+
"when": "view == javaProjectExplorer && viewItem =~ /java:(type|package|packageRoot)(?=.*?\\b\\+uri\\b)(?=.*?\\b\\+test\\b)(?!.*?\\b\\+resource\\b)/",
9898
"group": "8_execution@20"
9999
},
100100
{
101101
"command": "java.test.runFromJavaProjectExplorer",
102-
"when": "view == javaProjectExplorer && viewItem =~ /java:(type|package|packageRoot)(?=.*?\\b\\+uri\\b)(?=.*?\\b\\+source\\b)(?=.*?\\b\\+test\\b)/",
102+
"when": "view == javaProjectExplorer && viewItem =~ /java:(type|package|packageRoot)(?=.*?\\b\\+uri\\b)(?=.*?\\b\\+test\\b)(?!.*?\\b\\+resource\\b)/",
103103
"group": "inline@run_0"
104104
}
105105
],

src/commands/projectExplorerCommands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function runTestsFromJavaProjectExplorer(node: any, isDebug: boolea
3232
const nodeFsPath: string = Uri.parse(node._nodeData.uri).fsPath;
3333
projectItem.children.forEach((child: TestItem) => {
3434
const itemPath: string = child.uri?.fsPath || '';
35-
if (isHierarchicalMode || node._nodeData.kind === 4 /*packageRoot*/) {
35+
if (isHierarchicalMode || node._nodeData.kind === 3 /*packageRoot*/) {
3636
// if the selected node is a package root or the view is in hierarchical mode,
3737
// all the test items whose path start from the path of the selected node will be added
3838
if (itemPath.startsWith(nodeFsPath)) {
@@ -55,7 +55,7 @@ export async function runTestsFromJavaProjectExplorer(node: any, isDebug: boolea
5555
function getTestLevel(nodeData: any): TestLevel {
5656
// The command will only register on the class/package/packageRoot
5757
// nodes of the Java Project explorer
58-
if (nodeData.kind === 6 /*PrimaryType*/) {
58+
if (nodeData.kind === 5 /*PrimaryType*/) {
5959
return TestLevel.Class;
6060
} else {
6161
return TestLevel.Package;

0 commit comments

Comments
 (0)