To use this functionality, the LLM provider must first be configured in the Parasoft Preferences. For details, see Configuring LLM Provider Settings.
This feature depends on LLMs, which may produce inaccurate information.
Follow these steps to improve a selected test with AI:
- Select a test method in the editor and then click the Improve [method_name] with AI button in the Unit Test Assistant view.
2. The Improve [method_name] with AI window appears.
Specify the following:
- Improvement type: Select the type of improvement you want to make.
- Convert to parameterized test - Converts the selected test to a parameterized format with rows of data to cover different code paths.
- Add edge and error cases - Expands the test to include additional input value cases to cover as many lines of code in the method under test as possible.
- Custom - Makes changes to the test based on user-provided instructions.
- Prompt history: Select a prompt. The drop-down list contains default example prompts and previously submitted prompts.
- User prompt text area: Include any extra details/instructions you would like to submit to the LLM provider.
3. Click Submit to send the query to the LLM provider and receive a result.
The LLM provider returns the results as a stream of text. In most cases this will be the updated version of the test, but it might also include an explanation of the code.
The initial LLM provider response for the unit test improvements is always in English. When the language selected for Jtest is Chinese or Japanese, the Translate button is also available, which enables users to translate the initial response into their language. The button will be disabled if the original response from the LLM provider was empty or if the result has already been translated.
4. To apply the AI-generated solution, click the Apply button. A diff view of the code will open, allowing the user to edit the code if needed before appending it to the test class.
If the code cannot be appended to the existing class, a new test class is created and code is added there.