Overview

With Unit Test Assistant you can easily create test suites by choosing the Create test suite option in the Unit Test Assistant view or in your IDE context menu. When you choose the Create test suite option, UTA will:

  1. Analyze the methods in the selected scope.
  2. Create test cases.
  3. (Optional) Enhance generated tests using AI by creating improved variable values and attempting to fix failing generated tests. (UTA may create a limited number of failing tests that provide some coverage even though they fail. In this step, UTA uses AI to update the failing tests to make them pass.) 

    To use this functionality:

    This feature depends on LLMs, which may produce inaccurate information.
  4. Run the created tests using the Track and make assertions functionality to add assertions (see Tracking Object Changes and Creating Assertions for details).

    If you are using Eclipse IDE, the Build Automatically option (Project menu > Build Automatically) must be enabled for assertions to be added. If the option is disabled, no assertions are added during the test run

To customize test cases created by UTA, review the values and assertions in the test code and update them as necessary. In addition, you can re-run the tests with the Run option to enhance your tests cases using UTA recommendations (see Executing Unit Tests with Unit Test Assistant).

UTA requires 2 GB of RAM for bulk creation. If you create multiple test cases for a large code base, we recommend configuring your IDE to use 4 GB of RAM.

We recommend that you disable the Synchronize files on frame or editor tab activation option in the IntelliJ settings. If enabled, UTA may occasionally abort and then resume the test creation process, which may result in failing to generate one test, or generating a test that is incomplete. To disable the option:

  1. Go to File > Settings in your IntelliJ IDEA.
  2. Select Appearance & Behavior > System Settings.
  3. Disable the Synchronize files on frame or editor tab activation option.

UTA creates test for private methods in the selected classes if the Create tests for private methods option in the UTA Preferences is enabled (see Configuring Preferences). By default, the Create tests for private methods option is disabled, since the industry best practice is to test private methods by creating tests for the accessible methods that call them, rather than by creating tests for private methods directly.

You can specify the time limit for executing a test suite by configuring the Configure tests with timeout (in ms) option in the UTA Preferences (see Test creation options).

Creating a Test Suite for One File

  1. Open the Unit Test Assistant - Create test suite dialog in one of the following ways:

  2.   Configure the test creation options.

  3. Click OK. UTA will:
    1. create test cases for all the selected methods in the file (including methods that already have corresponding tests).
    2. run the tests to create assertions.
  4. Review the tests to modify the values and assertions if necessary.

     
  5. Run the test with UTA to collect coverage information and recommendations for possible improvements (see Executing Unit Tests with Unit Test Assistant).

Creating a Test Suite for Multiple Files

UTA can create test cases for more than one file at a time. You can create tests either for all methods in a set of specified files, or only for the modified methods in a set of files based on the comparison criteria you select.

You can decide to only add test cases that increase coverage by selecting this option in the UTA Preferences (see Test creation options).

  1. Right-click the files, package(s), or project(s) for which you want to create test cases. Also, you can select individual methods if they are in the same class (if you select methods from different classes, or an individual method and a class or package, test cases will not be created).
  2. Click Unit Testing > Create test suite to open the the Unit Test Assistant - Create test suite dialog.

  3. Configure the test creation options.
  4. (Optional) Hover over the License usage summary option to display an estimated number of tokens required to create test cases for the selected resources. Once the test are generated, the summary dialog will show how many tokens were actually consumed, and how many remain (see Licensing).
  5. Click OK. UTA will:
    1. create test cases, skipping the files that are not testable or whose corresponding test classes already exist.
    2. run the tests to create assertions.
  6. Run the tests with UTA to collect coverage information and recommendations for possible improvements (see Executing Unit Tests with Unit Test Assistant).

Creating tests for modified methods when compared to a local or remote branch requires the "Unit Test Single Class Creation" license feature, and no license tokens are consumed in this scenario. Creating tests for an entire selection, or for modified methods when compared to a specified commit or branch or since the current branch diverged from a specified commit or branch, requires one of the "Unit Test Bulk Creation Tier" license features. These features provide license tokens that are consumed based on the number of files for which test cases are generated (the number of tokens available depends on your license agreement). In these scenarios, UTA consumes one token per .java file for which tests are created.

  • Files for which UTA does not generate any test cases (for example, interfaces or abstract classes) do not consume a token.
  • Once a token has been consumed for a given java file, regenerating tests for that .java file does not consume another token, even if the first test is deleted.

If the results of bulk creation are poor, this might indicate setup problems in the project. For more information, see How can I diagnose potential setup problems?.