Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ describes its setup and restrictions.

Test method and class tasks use the `ZED_JAVA_RUNNABLE=test-method` and
`ZED_JAVA_RUNNABLE=test-class` markers. Their existing Run commands are preserved.
The locator creates a `testTarget` containing the source file, class, optional
outer class, and optional method. Discovery and compilation happen only when
The locator creates a `testTarget` containing the source file, package, class,
optional outer class, and optional method. Discovery and compilation happen only when
you select Debug; creating the gutter action does not contact a language server.
Project-wide test tasks are not converted to debug scenarios.

Expand All @@ -243,11 +243,14 @@ TestNG uses its bundled runner. A local callback socket receives the test runner
result protocol; this does not provide a test-results explorer. Build failures,
missing targets, and ambiguous method names stop the launch.

Test gutter debugging is available with the `Java` adapter. All invocations of a
parameterized method are selected together.
With a Scala extension that supports Java `testTarget`, selecting the `Metals`
adapter discovers the test build target and starts a test class or method through
Metals. Framework and build-server support for selecting individual methods may
vary. All invocations of a parameterized method are selected together with JDTLS.

Custom project tasks that replace the built-in Java tasks must also include the
appropriate marker. Select `Java` in `languages.Java.debuggers` for test debugging.
appropriate marker. Select the desired adapter in `languages.Java.debuggers` for
test debugging.

### Debugging with JDTLS

Expand Down
7 changes: 3 additions & 4 deletions src/debug_locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl JavaRunnable {
"path": "$ZED_FILE",
"runType": "runOrTestFile",
})),
(Self::TestMethod | Self::TestClass, "Java") => {
(Self::TestMethod | Self::TestClass, "Java" | "Metals") => {
let mut target = json!({
"file": "$ZED_FILE",
"className": "$ZED_CUSTOM_java_class_name",
Expand Down Expand Up @@ -211,8 +211,8 @@ mod tests {
let mut task = main_task();
task.env = vec![(RUNNABLE_ENV.into(), runnable.into())];

{
let scenario = create_scenario(task.clone(), "Debug test".into(), "Java").unwrap();
for adapter in ["Java", "Metals"] {
let scenario = create_scenario(task.clone(), "Debug test".into(), adapter).unwrap();
let config: Value = from_str(&scenario.config).unwrap();
assert_eq!(config["testTarget"]["file"], "$ZED_FILE");
assert_eq!(
Expand All @@ -226,7 +226,6 @@ mod tests {
runnable == "test-method"
);
}
assert!(create_scenario(task, "Debug test".into(), "Metals").is_none());
}
}

Expand Down