Share via


Quickstart: generate unit tests with GitHub Copilot App Modernization - upgrade for Java (preview)

This quickstart shows you how to generate unit tests using GitHub Copilot App Modernization - upgrade for Java (preview).

Prerequisites

Note

If you're using Gradle, only the Gradle wrapper version 5+ is supported. The Kotlin DSL isn't supported.

Sign in to use Copilot and then install the required extension

To use GitHub Copilot, sign in to your GitHub account in Visual Studio Code. Select the Copilot icon at the top of Visual Studio Code to access the GitHub Copilot pane. For more information about setting up GitHub Copilot, see Set up GitHub Copilot in VS Code.

Then, use the following steps to install the extension in Visual Studio Code:

  1. In Visual Studio Code, open the Extensions view from the Activity Bar.
  2. Search for GitHub Copilot App Modernization in the marketplace.
  3. Select the GitHub Copilot App Modernization extension pack.
  4. On the extension page, select Install.
  5. Restart Visual Studio Code.

After installation completes, you should see a notification in the corner of Visual Studio Code confirming success.

For more information, see Install a VS Code extension.

Launch GitHub Copilot Agent Mode and start the upgrade

Use the following steps to launch GitHub Copilot Agent Mode and generate unit tests:

  1. Select a Java project that uses either Maven or Gradle as its build tool.
  2. Open the selected Java project in Visual Studio Code.
  3. Open the GitHub Copilot Chat panel.
  4. Switch to Agent Mode.
  5. Enter a prompt such as Generate unit tests for this Java project.

Screenshot of Visual Studio Code that shows an example before unit test generation.

Wait for the test generation to complete

The App Modernization - Upgrade for Java (Preview) tool analyzes the Java project within the current workspace. This includes evaluating the project's JDK version, build tools, and any existing unit tests.

As part of the process, the tool generates a TestReport.md file that tracks test generation progress and provides a summary of test results both before and after test generation. The report includes the following details:

  • Total number of existing tests
  • Overall pass rate
  • Timestamp
  • Number of successful tests
  • Number of failed tests
  • Number of tests with errors

During test generation, the output displays progress messages - for example, "Generating unit tests for ..." - to indicate ongoing activity. The tool automatically generates test files and adds them to the workspace.

Review the generated tests

After test generation is complete, GitHub Copilot displays a detailed report summarizing the post-generation test results. This report includes the same metrics captured before test generation - such as the total number of tests, successes, failures, and errors - enabling you to easily compare and evaluate the changes introduced during the process.

Screenshot of Visual Studio Code that shows the unit test generation report.

See also

GitHub Copilot App Modernization - upgrade for Java (preview)