The agent can generate comprehensive, compilable unit tests
for your Kotlin and Java code. Powered by the model of your choice, the
agent analyzes your source code to identify constructor dependencies, business
logic branches, and edge cases, and then automatically creates a complete test
class. This includes the generation of setUp methods, mock initialization,
and individual test cases tailored to your project's specific architecture and
coding style.
The agent detects your project's existing configuration and uses the appropriate frameworks and mocking libraries. This helps you bootstrap test classes, saving you time on repetitive setup.
Generate unit tests from the editor
To generate unit tests from the Android Studio editor, do the following:
- Open a Kotlin or Java source file in the Android Studio editor.
- Right-click a class name or a specific method, or select a block of code, and then select AI > Generate Unit Tests.
Generate unit tests from the tool window
To ask the agent directly to generate unit tests, do the following:
- Click Agent in the tool window bar.
- Enter a request such as "Generate unit tests for this file" or "Write unit tests for MyClass".