diff --git a/test-fixtures/maven-resolve-type/README.md b/test-fixtures/maven-resolve-type/README.md new file mode 100644 index 00000000..397464c6 --- /dev/null +++ b/test-fixtures/maven-resolve-type/README.md @@ -0,0 +1,16 @@ +# Maven Resolve Unknown Type — Test Fixture + +This fixture is consumed by `test-plans/java-maven-resolve-type.yaml`. + +It is a minimal self-contained Maven project intentionally configured with +JDK 11 compliance (`11`), so JDT runs full semantic +analysis under the JDK 21 toolchain that the E2E workflow installs. This +avoids the historical problem of using fixtures with `1.7`, +which causes JDT to emit only syntactic warnings (e.g. "compiler +compliance 1.7 but JRE 11 is used") and silently skip semantic +diagnostics — making the `Gson cannot be resolved to a type` error never +surface and breaking the `Resolve unknown type` Code Action assertion. + +The plan inserts `Gson gson;` into `App.java`, expects JDT to publish the +unresolved-type diagnostic, and then exercises `vscode-maven`'s +`Resolve unknown type` Code Action. diff --git a/test-fixtures/maven-resolve-type/pom.xml b/test-fixtures/maven-resolve-type/pom.xml new file mode 100644 index 00000000..b8d493e8 --- /dev/null +++ b/test-fixtures/maven-resolve-type/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + com.example + maven-resolve-type + 1.0.0-SNAPSHOT + + + + maven-compiler-plugin + 3.8.0 + + 11 + + + + + diff --git a/test-fixtures/maven-resolve-type/src/main/java/com/example/App.java b/test-fixtures/maven-resolve-type/src/main/java/com/example/App.java new file mode 100644 index 00000000..b7c2e1a4 --- /dev/null +++ b/test-fixtures/maven-resolve-type/src/main/java/com/example/App.java @@ -0,0 +1,6 @@ +package com.example; + +public class App { + public static void main(String[] args) { + } +} diff --git a/test-plans/java-maven-resolve-type.yaml b/test-plans/java-maven-resolve-type.yaml index 3fd4efc8..6b89f309 100644 --- a/test-plans/java-maven-resolve-type.yaml +++ b/test-plans/java-maven-resolve-type.yaml @@ -4,11 +4,14 @@ # Verify: Type unknown type → hover shows "Resolve unknown type" → add dependency and import # # Prerequisites: -# - vscode-java repo cloned locally -# - JDK installed and available -# - Maven installed +# - JDK 11+ installed and available on PATH (the workflow installs JDK 21) +# - Maven installed (or the redhat.java embedded one) # # Usage: autotest run test-plans/java-maven-resolve-type.yaml +# +# Fixture: test-fixtures/maven-resolve-type — self-contained, owned by this +# repo. Uses JDK 11 compliance to ensure JDT runs full semantic analysis +# and publishes the unresolved-type diagnostic (see fixture README). name: "Maven for Java — Resolve Unknown Type" description: | @@ -21,7 +24,7 @@ setup: extensions: - "vscjava.vscode-java-pack" vscodeVersion: "stable" - workspace: "../../vscode-java/test/resources/projects/maven/salut" + workspace: "../test-fixtures/maven-resolve-type" timeout: 90 steps: @@ -32,20 +35,22 @@ steps: timeout: 120 # ── Open Java file ────────────────────────────────────── - - id: "open-foo" - action: "open file Foo.java" - verify: "Foo.java file is open in the editor" + - id: "open-app" + action: "open file App.java" + verify: "App.java file is open in the editor" timeout: 15 # ── Type unknown type ───────────────────────────────────────── - # wiki: "type 'Gson gson;'" — use insertLineInFile so LS detects the change + # wiki: "type 'Gson gson;'" — use insertLineInFile so LS detects the change. + # Line 4 places the field directly inside the class body of App.java. - id: "insert-unknown-type" - action: "insertLineInFile src/main/java/java/Foo.java 10 Gson gson;" + action: "insertLineInFile src/main/java/com/example/App.java 4 Gson gson;" waitBefore: 3 # ── Verify Code Action: Resolve unknown type ──────────── - # wiki: hover shows "Resolve unknown type" → apply Code Action - # Wait for LS to detect the Gson error before navigating + # wiki: hover shows "Resolve unknown type" → apply Code Action. + # navigateToError polls for diagnostics up to 30s and fails clearly if + # the LS hasn't published the unresolved-type error yet. - id: "navigate-to-error" action: "navigateToError 1" waitBefore: 5