Skip to content

Test Plan

Jinbo Wang edited this page Sep 14, 2023 · 17 revisions

Feature Test Plan

Environment Setup

  • 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
  • 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

Test platform

  • Windows
  • macOS
  • Linux

Scenarios

Basic

  1. Open https://github.com/redhat-developer/vscode-java/tree/master/test/resources/projects/eclipse/simple-app.

  2. After the language server is initialized, check the status bar icon is 👍, and the problems view has two errors.

  3. 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 {
    
    
    }
  4. 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.

  5. Save all the files, and invoke VSCode command Java: Force Java compilation. There should be no errors.

  6. 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");
  7. 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.
  8. 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 to FooNew. Verify that all appearance of the Foo symbol in both Bar.java and Foo.java files are updated to FooNew.
    • 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 the FooNew symbols in both Bar.java and FooNew.java files are updated back to Foo.
  9. 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 {
    
    }

Maven

  1. Open https://github.com/redhat-developer/vscode-java/tree/master/test/resources/projects/maven/salut.
  2. After the language server is initialized, check the status bar icon is 👍, and the problems views has several warnings but without errors.
  3. Editing experience is correctly working including diagnostics, code completion and code actions.

Maven - Multimodule

  1. Open https://github.com/redhat-developer/vscode-java/tree/master/test/resources/projects/maven/multimodule.
  2. After the language server is initialized, check the status bar icon is 👍, and there should be no errors/warning in the problems view.
  3. 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

Gradle

  1. Open https://github.com/redhat-developer/vscode-java/tree/master/test/resources/projects/gradle/simple-gradle
  2. After the language server is initialized, check the status bar icon is 👍, and there should be no errors/problems in the problems view.
  3. Open Foo.java file, make sure the editing experience is correctly working including diagnostics, code completion and code action

Maven - Java 11

  1. Install JDK 11, and change the VSCode java.home to the JDK 11 path.
  2. Open https://github.com/redhat-developer/vscode-java/tree/master/test/resources/projects/maven/salut-java11.
  3. After the language server is initialized, check the status bar icon is 👍, and there should be no errors/problems in the problems view.
  4. Open Bar.java, make sure the editing experience is correctly working including diagnostics, code completion and code action

Gradle - Java 11

  1. Install JDK 11.
  2. Open https://github.com/redhat-developer/vscode-java/tree/master/test/resources/projects/gradle/gradle-11.
  3. After the language server is initialized, check the status bar icon is 👍, and there should be no errors/problems in the problems view.
  4. Open Foo.java file, make sure the editing experience is correctly working including diagnostics, code completion and code action.

Single file

  1. Open/Create an empty folder
  2. Add a new Java file, name it Test.java. Check the language server is initialized, and the status bar icon is 👍 after that.
  3. Type code snippet class to generate the class body, type main to generate the main methods.
  4. In the Test.java file, make sure the editing experience is correctly working including diagnostics, code completion and code action.

Single file without workspace

  1. Open an empty VS Code window.
  2. 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.
  3. Wait for Java extension to be ready (the status bar icon is 👍).
  4. Try the basic editing features in App.java, they should work.
  5. Try debugging the App.java, it should work.

Fresh import - Verify if the project import works when importing a fresh maven/gradle repo.

  1. 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.
  2. 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.

Third-party plugin compatibility

Visual Studio IntelliCode

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

Should complete type names well.

  • Steps

    Str
  • Expected

    The completion list should include "String - java.lang".

Should complete constructors well.

  • Steps

    java.util.List<String> list = new Array
  • Expected

    The completion list should include "ArrayList()".

Should show static methods.

  • Steps

    String.▮
  • Expected

    Static members are listed, likely with starred items on top of the list.

Should include parameters in method completion.

  • 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▮)

Should complete package name as before.

  • Steps

    import java.▮
  • Expected

    Packages are listed in alphabetical order.

Should work well with method chaining.

  • Steps

    import java.util.Arrays;
    
    ...
    
    Arrays.asList("a", "b").▮
  • Expected

    Completion items are listed, with starred items on the top.

Correct icons

  • 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.

In if conditional

  • 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.

Recommedation comes only from previous two invocations.

  • 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.

static snippets are correctly resolved.

  • 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 {
    
        ▮
    }

Debugger for Java

Java Test Runner

Open the project: https://github.com/junit-team/junit5-samples/tree/master/junit5-migration-maven

  1. The test explorer can show test case.
  2. Can run the test cases by clicking Run All in test explorer
  3. Open a Java test file, the Code Lens could show above each test cases
  4. Can run the test cases by clicking the Run Test Code Lens

Maven for Java

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

Java Dependency Viewer

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.

Java Extension Pack

Trigger the command Java: Configure Classpath. Two possible view will appear:

  1. 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.
  1. Native VS Code setting page, side with a document.