With AI Assistant, you can generate unit tests for code segments. AI Assistant analyzes both your code and its documentation to recommend tests that will provide insights into your code's behavior.
Place the caret somewhere within a class or a specific method and right-click to open the context menu.
Alternatively, press AltEnter.
Select AI Actions and then Generate Unit Tests.
The generated test opens in a separate AI Diff tab.
If you want to improve the generated code, click Specify, add new requirements, and press Enter.
If you want to regenerate the answer, click Regenerate.
If you want to modify the prompt, click Customize Prompt and provide new instructions. The changes will take effect from the next test generation attempt.
Click Accept all to save the generated test.
It will be shown as a new file in a separate tab.
If you already have a test module in your project, the new test will be stored there. If not, the new test will be stored next to the source file.
tip
If you are developing a custom plugin, and you want to enhance or fine-tune the test generation functionality provided by AI Assistant, you can do so by using the com.intellij.ml.llm.generateTestsSupportextension point.
Thanks for your feedback!
Was this page helpful?
Cookie Settings
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions. Learn more.
With your consent, JetBrains may also use cookies and your IP address to collect individual statistics and provide you with personalized offers and ads subject to the Privacy Notice and the Terms of Use. JetBrains may use third-party services for this purpose. You can adjust or withdraw your consent at any time by visiting the Opt-Out page.