This topic explains how to configure Unit Test Assistant.
In this section:
To configure the general UTA options, choose Parasoft> Preferences> Unit Test Assistant.
This option allows you to specify where tests created with UTA are saved. You can select a pattern from the drop-down menu or manually customize the pattern with the following predefined variables:
${class_name}
- The name of the tested class.${package_name}
- The name of the package that includes the tested class.${source_folder}
- The name of the folder that contains the source files of the project.${project_name}
- The name of the project that includes the tested class.${test_kind}
- The name of the test type, which will be added to the file name. This variable can take the following values:
- Spring
- Separates Spring tests from other tests in JUnit 4 and 5.
- Parameterized
- Separates parameterized tests from regular tests in JUnit 4. In JUnit 5, regular and parameterized test cases are added to the same file.
This option allows you to specify the testing framework UTA will use to create new tests. You can choose JUnit 4 or JUnit 5.
This option allows you to enable creating unit tests for private methods. When enabled:
This option allows you to specify the time limit (in milliseconds) for executing a test suite created with the Create test suite option. If the time limit is exceeded, the test execution will stop, the test suite will fail, and the information about the error will be displayed as a Recommendation in the UTA interface. See Creating Test Suites.
With this option enabled, UTA automatically generates assertion templates as comments in code when a basic test case is created. See Creating a Basic Unit Test for details.
This option does not apply when test suites are created with the Create test suite option. |
With this option enabled, UTA:
See Configuring Factory Methods for details.
With this option enabled, UTA displays action links that allow you to create parameterized test cases. See Creating a Parameterized Unit Test.
Parameterized tests depend on the testing framework you configured with the Testing framework for new tests option:
This option does not apply when test suites are created with the Create test suite option. |
Advanced settings allow you to configure input data for creating parameterized test cases.
This option specifies the maximum number of rows with parameter variants that will be created for one test case.
This option specifies where the test cases are saved. You can choose Code (default) or CSV from the drop-down menu.
|
This set of options allows you to customize the default list of values by selecting a data type from the Select type drop-down menu and adding, editing, or removing the values in the list. The Find field allows you to conveniently search for a particular value.
When you add new values, the characters must match the character encoding that will be used to save the files to ensure that the files are properly generated. |
With this option enabled, UTA displays action links that allow you to create Spring test cases. See Creating a Spring Unit Test.
This option does not apply when test suites are created with the Create test suite option. |
This option allows you to specify the attributes to be included in the ContextConfiguration annotation when a Spring test is created. See Configuring Spring tests with the ContextConfiguration Annotation.
Configuring UTA execution monitor options allows you to specify the limits for collecting data during test execution. In addition, to prevent exceeding the limits, you can specify packages and classes you want to exclude from monitoring when executing tests with UTA.
To configure the mocking options for UTA options, choose Parasoft> Preferences> Unit Test Assistant> Execution Monitor.
This option allows you to specify a list of packages and classes to be excluded from monitoring. Click New and provide a qualified name of a package or class (wildcards are not supported).
This set of options allows you to specify the limits for collecting data during execution:
To configure the mocking options for UTA options, choose Parasoft> Preferences> Unit Test Assistant> Mocking.
This option enables or disables mocking objects during test creation and execution.
This option enables or disables using helper methods. If enabled, generated tests classes will separate regular test methods from helper methods that prepare objects but do not make assertions.
Since version 2022.1, static method and constructor mocks are created with Mockito. To use this functionality you need to update your project to include a version of Mockito that supports mocks for static methods and constructors. If you want to continue to use Powermock with Mockito for hand-written mocks, version 3.12.4 of Mockito is recommended. Any tests that use PowerMock and were created prior to version 2022.1 with Jtest or manually may need to be updated to avoid test failures; see What if tests fail when running PowerMock with mockito-inline? |
UTA automatically mocks methods which match the patterns specified in the table. Click New to add a new method or pattern. Use qualified method names and wildcards (*) to match patterns. The patterns that end with .*
or <init>
will be matched with constructors. For example, the following configuration will mock:
DAO
classes in all sub-packages of "com.example".InternalUtil
class.If the specified pattern matches all methods of a class, UTA will use the mockStatic()
method to mock static methods of a class. For details about the mockStatic() method, see mockStatic.
Only the static methods and constructors specified in the table will be mocked. UTA will automatically add mocks to test templates during test creation, or display recommendations that will help you add mocks after your tests are run (see Creating Mocks).
You can specify which type of recommendations UTA displays after test execution.
To configure UTA recommendations, choose Parasoft> Preferences> Unit Test Assistant> Recommendations.
You can enable or disable the following recommendation types:
See Executing Unit Tests with Unit Test Assistant for examples of recommendations displayed by UTA.