Skip to content

Test Plan

Yan Zhang edited this page Feb 13, 2020 · 17 revisions

Feature Test Plan

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.

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.

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

Clone this wiki locally