fix(run): run a Gradle test with the Test task of its source set (#8207)

Run and Debug from the gutter on a test in a JVM test suite (src/integrationTest/java) or in a source set with its own Test task (functionalTest) ran `:app:test --tests ...`, and Gradle answered "No tests found for given includes": the run configurations only knew a test task and every Gradle test run was narrowed to <project>:test.

The Gradle sync now reports, for each source set, the Test tasks whose testClassesDirs hold its classes (GradleProject.testTasks), and a test file, class, method or folder runs with the task of its source set (`:app:integrationTest --tests demo.GreeterIT`); those folders also get the All Tests and package runs src/test/java has, and debugging a configuration that runs such a task gets the JDWP agent. Before a sync reports the tasks, runs keep using test; older Gradle caches are marked stale so the next reload reads them.

Co-authored-by: ntbang0901 <[email protected]>
Цей коміт міститься в:
ntbang0901 authored and GitHub committed 2026-12-05 18:29:35 +08:00
1 джерело bb7cacb357
коміт 7911a74c05
12 files changed
+330 -19

No files matched your search

+38
Переглянути файл
@@ -9,6 +9,7 @@ import {
parseJavaArgs,
resolveJavaCommand,
} from "@/platform/javaLaunch";
import { useBuildModel } from "@/platform/buildModel";
import { usePlatform } from "@/platform/platformInfo";
import { useProject } from "@/platform/project";
import { applicationConfig, jvmModuleDir, jvmTestConfig } from "./application";
@@ -492,6 +493,43 @@ describe("debugging build tool configurations", () => {
expect(jdwpLaunch(cfg({ id: "n", kind: "npm", args: ["test"] }))).toBeNull();
});
it("debugs the Test tasks Gradle reported, whatever their name", () => {
const functional = cfg({ id: "ft", kind: "gradle", args: [":app:functionalTest"] });
expect(jdwpLaunch(functional)).toBeNull();
useBuildModel.setState({
model: {
maven: null,
sbt: [],
gradle: [
{
dir: "",
projects: [
{
path: ":app",
name: "app",
dir: "app",
buildFile: null,
tasks: [],
testTasks: [{ name: "functionalTest", sourceFolders: ["app/src/functionalTest/java"] }],
},
],
javaVersion: null,
command: "gradle",
env: {},
syncedAt: 1,
stale: false,
syncError: null,
},
],
},
} as never);
try {
expect(jdwpLaunch(functional)!.args).toEqual([":app:functionalTest", DELEGATED_DEBUG]);
} finally {
useBuildModel.setState({ model: null });
}
});
const AGENT = /-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=127\.0\.0\.1:0$/;
it.each([