-
Notifications
You must be signed in to change notification settings - Fork 134
Test Plan
- Ensure that you have a clean machine by deleting the VS Code cache, such as:
- The extension directory (for example,
C:\Users\name\.vscode
on Windows) - The VS Code global storage (for example,
C:\Users\name\AppData\Roaming\Code
) - The settings.json file
- The extension directory (for example,
- JDK installtion
- Avoid using SDK tools (such as sdkman) to install JDK
- Leave all JDK related settings (e.g.
java.jdt.ls.java.home
,java.import.gradle.java.home
,java.configuration.runtimes
) as empty and test if Java extension can startup
- Windows
- macOS
- Linux
-
After the language server is initialized, check the status bar icon is 👍, and the problems view has two errors.
-
Select Foo.java file, invoke
class
code snippet to generate code as below and the problem view error number is reduced to 1.package app; /** * Foo */ public class Foo { }
-
Click the remain error in the diagnostic window, the code action icon should pop up both on the problems view and the side bar of the editor. Select the code action of
Create method 'call()' in type 'Foo'
to fix the error. -
Save all the files, and invoke VSCode command
Java: Force Java compilation
. There should be no errors. -
Typing the following file of code into the
App.main
method, the completion should work for File and there should be two errors in the problem view.File f = new File("demo.txt");
-
Organize Imports:
- Invoke the context menu command
Source Action...
==>Organize Imports
, there should be only one warning remains in the problem view. - You also can type F1 ->
Organize Imports
, it should have the same result.
- Invoke the context menu command
-
Verify Rename feature:
- Rename from the editor context menu: Open Foo.java file, select the definition of class
Foo
, right click and run "Rename Symbol" menu to rename it toFooNew
. Verify that all appearance of theFoo
symbol in both Bar.java and Foo.java files are updated toFooNew
. - Rename from File Explorer: Find the previously renamed file FooNew.java in the File Explorer, right click it and run "Rename" menu to rename it to
Foo
. Verify that all appearances of theFooNew
symbols in both Bar.java and FooNew.java files are updated back toFoo
.
- Rename from the editor context menu: Open Foo.java file, select the definition of class
-
New Java file snippet
- Go to File Explorer view and select the folder "eclipse/simple-app/src/app".
- Right click on "app" folder, and run "New File" menu.
- Input file name with "Hello.java".
- Verify that a new file snippet is generated.
package app; public class Hello { }
- Open https://github.com/redhat-developer/vscode-java/tree/master/test/resources/projects/maven/salut.
- After the language server is initialized, check the status bar icon is 👍, and the problems views has several warnings but without errors.
- Editing experience is correctly working including diagnostics, code completion and code actions.
- Open https://github.com/redhat-developer/vscode-java/tree/master/test/resources/projects/maven/multimodule.
- After the language server is initialized, check the status bar icon is 👍, and there should be no errors/warning in the problems view.
- Open
Foo.java
file, make sure the editing experience is correctly working including diagnostics, code completion and code action on both modules.- module1\Foo.java
- module2\Foo.java
- Open https://github.com/redhat-developer/vscode-java/tree/master/test/resources/projects/gradle/simple-gradle
- After the language server is initialized, check the status bar icon is 👍, and there should be no errors/problems in the problems view.
- Open
Foo.java
file, make sure the editing experience is correctly working including diagnostics, code completion and code action
- Install JDK 11, and change the VSCode java.home to the JDK 11 path.
- Open https://github.com/redhat-developer/vscode-java/tree/master/test/resources/projects/maven/salut-java11.
- After the language server is initialized, check the status bar icon is 👍, and there should be no errors/problems in the problems view.
- Open
Bar.java
, make sure the editing experience is correctly working including diagnostics, code completion and code action
- Install JDK 11.
- Open https://github.com/redhat-developer/vscode-java/tree/master/test/resources/projects/gradle/gradle-11.
- After the language server is initialized, check the status bar icon is 👍, and there should be no errors/problems in the problems view.
- Open
Foo.java
file, make sure the editing experience is correctly working including diagnostics, code completion and code action.
- Open/Create an empty folder
- Add a new Java file, name it Test.java. Check the language server is initialized, and the status bar icon is 👍 after that.
- Type code snippet
class
to generate the class body, typemain
to generate the main methods. - In the Test.java file, make sure the editing experience is correctly working including diagnostics, code completion and code action.
- Open an empty VS Code window.
- Drag a Java file https://github.com/redhat-developer/vscode-java/blob/master/test/resources/projects/eclipse/simple-app/src/app/App.java to it.
- Wait for Java extension to be ready (the status bar icon is 👍).
- Try the basic editing features in App.java, they should work.
- Try debugging the App.java, it should work.
- Clone https://github.com/spring-projects/spring-petclinic to an empty directory, and then open the new project in VS Code. Check LS status bar is 👍 and basic language features such as completion works.
- Clone https://github.com/spring-guides/gs-spring-boot to an empty directory, and then open the new project
gs-spring-boot/complete
in VS Code. Check LS status bar is 👍 and basic language features such as completion works.
Open a Java project in VS Code, input the code snippet in each test case, and verify whether the completion works as expected.
▮ - Cursor position
-
Steps
Str▮
-
Expected
The completion list should include "String - java.lang".
-
Steps
java.util.List<String> list = new Array▮
-
Expected
The completion list should include "ArrayList()".
-
Steps
String.▮
-
Expected
Static members are listed, likely with starred items on top of the list.
-
Steps
String a = “”; a.▮
Select an item, e.g.
equals(anObject)
. -
Expected
The code is completed with parameters, the first parameter is selected, as the following:
String a = ""; a.equals(anObject▮)
-
Steps
import java.▮
-
Expected
Packages are listed in alphabetical order.
-
Steps
import java.util.Arrays; ... Arrays.asList("a", "b").▮
-
Expected
Completion items are listed, with starred items on the top.
-
Steps
Write some simple code, e.g.
import java.util.ArrayList; import java.util.List; public class DemoApplication { public static void main(String[] args) { String message = String.join(" ", args); System.out.println(message); List<String> stringList = new ArrayList<>(); stringList.add(message); } }
-
Expected
Icons of completion items should be correct. e.g
java.util.ArrayList
should have the package icon,String
should have the class icon,join
should have the method icon.
-
Steps
In a simple application, write following code:
a)
String a = ""; a.▮
b)
String a = ""; if (a.▮)
-
Expected
a) and b) should have different recommedations.
-
Steps
In a simple application, write following code:
a)
String a = "[a,b,c]"; if (a.startsWith("[") && a.endsWith("]")) { a.▮ }
b)
String a = "[a,b,c]"; if (a.contains(",")) { String[] arr = a.split(","); System.out.println(String.join("\n", arr)); } if (a.startsWith("[") && a.endsWith("]")) { a.▮ }
c)
String a = "[a,b,c]"; if (a.startsWith("[") && a.endsWith("]")) { a.▮ } if (a.contains(",")) { String[] arr = a.split(","); System.out.println(String.join("\n", arr)); }
-
Expected
a) b) and c)should have the same recommendations.
-
Steps
Create a new .java file, e.g.
HelloWorld.java
.class▮
From the completion item list, select the one of the type "Snippet".
-
Expected
It should generate following code according to the package.
/** * HelloWorld */ public class HelloWorld { ▮ }
- Can start debug sessions for the following projects. Should verify if the breakpoint is hit and program output is as expected.
- Maven (https://github.com/spring-projects/spring-petclinic)
- Gradle
- Open https://github.com/eclipse/eclipse.jdt.ls/tree/master/org.eclipse.jdt.ls.tests/projects/gradle/simple-gradle, create a main class with main method, and then run it against JDK8
- Open https://github.com/eclipse/eclipse.jdt.ls/tree/master/org.eclipse.jdt.ls.tests/projects/gradle/gradle-13, change the main method declaration in
Foo.java
to "public static void main(String[] args)", and then run it against the latest JDK
- Single Folder project
- Open the project https://github.com/testforstephen/singlefolderdemo
- Should Run & Debug LucenceTest against both JDK 8 and the latest JDK version.
- Should Run & Debug Java13Feature against the latest JDK version (JDK13 and above).
- Encoding (https://github.com/microsoft/vscode-java-debug/tree/test_samples/testprojects/14.encoding)
Open the project: https://github.com/junit-team/junit5-samples/tree/master/junit5-migration-maven
- The test explorer can show test case.
- Can run the test cases by clicking
Run All
in test explorer - Open a Java test file, the Code Lens could show above each test cases
- Can run the test cases by clicking the
Run Test
Code Lens
Open a Maven project in VS Code, and open a .java file. In body of a function, type below statements.
Gson gson;
StringUtils.capitalize("abc");
Check if:
- When hovering on the classname, "Resolve unknown type" action is shown.
- When open Code Actions, "Resolve unknown type" is in the list.
- By clicking "Resolve unknown type", following the instructions, it can
- add related dependency into pom.xml
- add related import statement into the .java file
Open the project: https://github.com/junit-team/junit5-samples/tree/master/junit5-migration-maven
- The dependency explorer can show:
- Sources
- JDK libraries
- Maven Dependencies
Open the project: https://github.com/jdneo/invisble-project
- The libraries could be added/removed by clicking buttons in the dependency explorer's
Referenced Libraries
node. - After adding the folder
test-lib
into the referenced libraries, the compilation errors should disappear.
Trigger the command Java: Configure Classpath
. Two possible view will appear:
- A classpath configuration webview.
- Can configure source paths, output path, and referenced libraries for unmanaged folder.
- Can view above components for projects with build tools.
- Native VS Code setting page, side with a document.