Skip to content

Commit

Permalink
fix: Cannot run tests from Java Projects view (#1575)
Browse files Browse the repository at this point in the history
Signed-off-by: Sheng Chen <sheche@microsoft.com>
  • Loading branch information
jdneo authored May 31, 2023
1 parent 394f15f commit 8d92744
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
],
Expand Down
4 changes: 2 additions & 2 deletions src/commands/projectExplorerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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;
Expand Down

0 comments on commit 8d92744

Please sign in to comment.