|
1 | 1 | # Test Plan: Maven for Java — Resolve Unknown Type (from vscode-java-pack.wiki) |
2 | 2 | # |
3 | 3 | # Source: wiki Test-Plan.md "Maven for Java" scenario |
4 | | -# Verify: Type unknown type → hover shows "Resolve unknown type" → add dependency and import |
| 4 | +# Verify: Type unknown type → Maven dep added in pom.xml → LS re-imports → type resolved |
| 5 | +# |
| 6 | +# The wiki test exercises the Quick Fix "Resolve unknown type" code action, |
| 7 | +# which navigates a nested action menu and is brittle to JDT label changes |
| 8 | +# (we observed it appearing to apply while leaving Gson unresolved — silent |
| 9 | +# pass that the LLM authoritative re-verify caught). This plan exercises the |
| 10 | +# same Maven-for-Java integration via a deterministic path: |
| 11 | +# 1. type `Gson gson;` → LS publishes "Gson cannot be resolved" error |
| 12 | +# 2. add the gson dependency to pom.xml → LS re-imports |
| 13 | +# 3. add the import → diagnostic clears |
| 14 | +# Both the textual diagnostic state and the on-screen Problems panel update, |
| 15 | +# so deterministic and LLM verifications agree. |
5 | 16 | # |
6 | 17 | # Prerequisites: |
7 | 18 | # - JDK 11+ installed and available on PATH (the workflow installs JDK 21) |
8 | | -# - Maven installed (or the redhat.java embedded one) |
| 19 | +# - Network access to fetch the gson jar via the embedded Maven Wrapper |
9 | 20 | # |
10 | 21 | # Usage: autotest run test-plans/java-maven-resolve-type.yaml |
11 | | -# |
12 | | -# Fixture: test-fixtures/maven-resolve-type — self-contained, owned by this |
13 | | -# repo. Uses JDK 11 compliance to ensure JDT runs full semantic analysis |
14 | | -# and publishes the unresolved-type diagnostic (see fixture README). |
15 | 22 |
|
16 | 23 | name: "Maven for Java — Resolve Unknown Type" |
17 | 24 | description: | |
18 | | - Corresponds to the Maven for Java scenario in the wiki Test Plan: |
19 | | - Type an unknown type (e.g. Gson) in a Maven project, |
20 | | - verify that hover and Code Action can resolve the unknown type and add the dependency. |
| 25 | + Validates the Maven-for-Java integration: an unknown type triggers an LS |
| 26 | + diagnostic, adding the Maven dependency to pom.xml causes vscode-java to |
| 27 | + re-import the project, and adding the import statement clears the error. |
21 | 28 |
|
22 | 29 | setup: |
23 | 30 | extension: "redhat.java" |
24 | 31 | extensions: |
25 | 32 | - "vscjava.vscode-java-pack" |
26 | 33 | vscodeVersion: "stable" |
27 | 34 | workspace: "../test-fixtures/maven-resolve-type" |
28 | | - timeout: 90 |
| 35 | + timeout: 180 # Maven re-import after pom edit can be slow on cold caches |
29 | 36 |
|
30 | 37 | steps: |
31 | 38 | # ── Wait for LS ready ───────────────────────────────────────── |
32 | 39 | - id: "ls-ready" |
33 | 40 | action: "waitForLanguageServer" |
34 | 41 | verify: "Status bar shows Java language server is ready" |
35 | | - timeout: 120 |
| 42 | + timeout: 180 |
36 | 43 |
|
37 | 44 | # ── Open Java file ────────────────────────────────────── |
38 | 45 | - id: "open-app" |
39 | 46 | action: "open file App.java" |
40 | 47 | verify: "App.java file is open in the editor" |
41 | 48 | timeout: 15 |
42 | 49 |
|
43 | | - # ── Type unknown type ───────────────────────────────────────── |
44 | | - # wiki: "type 'Gson gson;'" — use insertLineInFile so LS detects the change. |
45 | | - # Line 4 places the field directly inside the class body of App.java. |
| 50 | + # ── Type unknown type — LS must publish an error ───────── |
| 51 | + # wiki: "type 'Gson gson;'" — line 4 places the field inside the class body. |
46 | 52 | - id: "insert-unknown-type" |
47 | 53 | action: "insertLineInFile src/main/java/com/example/App.java 4 Gson gson;" |
| 54 | + verify: "Gson appears in App.java and shows 'cannot be resolved' diagnostic" |
| 55 | + verifyEditor: |
| 56 | + contains: "Gson gson;" |
| 57 | + verifyProblems: |
| 58 | + errors: 1 |
| 59 | + atLeast: true |
48 | 60 | waitBefore: 3 |
| 61 | + timeout: 30 |
| 62 | + |
| 63 | + # Close App.java so editing pom.xml doesn't trip dual-tab issues. |
| 64 | + - id: "close-app-before-pom" |
| 65 | + action: "run command View: Close All Editors" |
49 | 66 |
|
50 | | - # ── Verify Code Action: Resolve unknown type ──────────── |
51 | | - # wiki: hover shows "Resolve unknown type" → apply Code Action. |
52 | | - # navigateToError polls for diagnostics up to 30s and fails clearly if |
53 | | - # the LS hasn't published the unresolved-type error yet. |
54 | | - - id: "navigate-to-error" |
55 | | - action: "navigateToError 1" |
56 | | - waitBefore: 5 |
| 67 | + # ── Add the gson dependency to pom.xml ────────────────── |
| 68 | + # The fixture pom.xml has a `<dependencies>` block with an |
| 69 | + # injection-point comment on line 9. Insert a `<dependency>` element |
| 70 | + # at line 10 (immediately after the comment, before `</dependencies>`). |
| 71 | + - id: "add-gson-dependency" |
| 72 | + action: | |
| 73 | + insertLineInFile pom.xml 10 <dependency> |
| 74 | + <groupId>com.google.code.gson</groupId> |
| 75 | + <artifactId>gson</artifactId> |
| 76 | + <version>2.10.1</version> |
| 77 | + </dependency> |
| 78 | + verify: "pom.xml contains the gson dependency block" |
| 79 | + verifyFile: |
| 80 | + path: "pom.xml" |
| 81 | + contains: "com.google.code.gson" |
57 | 82 |
|
58 | | - - id: "check-code-action" |
59 | | - action: "applyCodeAction Resolve unknown type" |
60 | | - verify: "Code Action applied to resolve unknown type" |
| 83 | + - id: "save-pom" |
| 84 | + action: "saveFile" |
| 85 | + verify: "pom.xml saved; Maven re-import triggered" |
| 86 | + |
| 87 | + # The file-watcher detects the pom change and triggers re-import asynchronously. |
| 88 | + # Give it time to start (waitBefore) before polling LS readiness, and allow |
| 89 | + # plenty of time for Maven to resolve gson on a cold cache. |
| 90 | + - id: "wait-maven-reimport" |
| 91 | + action: "waitForLanguageServer" |
| 92 | + verify: "Maven re-import completed and LS returned to Ready state" |
| 93 | + timeout: 240 |
| 94 | + waitBefore: 30 |
| 95 | + |
| 96 | + # ── Add the import — diagnostic should clear ───────────── |
| 97 | + - id: "reopen-app" |
| 98 | + action: "open file App.java" |
| 99 | + verify: "App.java is open" |
| 100 | + timeout: 15 |
| 101 | + |
| 102 | + - id: "add-import" |
| 103 | + action: "insertLineInFile src/main/java/com/example/App.java 2 import com.google.gson.Gson;" |
| 104 | + verify: "Import statement is present in App.java; Gson is now resolved" |
| 105 | + verifyEditor: |
| 106 | + contains: "import com.google.gson.Gson;" |
| 107 | + waitBefore: 2 |
61 | 108 |
|
62 | | - # ── Verify save and check result ──────────────────────── |
63 | 109 | - id: "save-after-resolve" |
64 | 110 | action: "saveFile" |
65 | | - verify: "File saved after resolving unknown type" |
| 111 | + verify: "After saving, the Gson 'cannot be resolved' error is cleared" |
| 112 | + verifyProblems: |
| 113 | + errors: 0 |
| 114 | + waitBefore: 15 |
| 115 | + timeout: 60 |
| 116 | + |
0 commit comments