Updated on 2026-10-27 GMT+08:00

Unit Test Agent

The unit test agent (developer-test-agent) provides end-to-end test case generation, covering test design, test case generation, and intelligent test case repair. This function can accurately generate test cases that comply with the code logic, automatically identify compilation errors of generated test cases, and intelligently repair test cases with compilation errors, effectively improving the development efficiency and quality of test cases.

You can invoke the unit test agent "developer-test-agent" in either of the following ways:

  • Method 1: Enter the agent name to invoke it.

    In the text box, enter a prompt containing the keyword "developer-test-agent". For example, use developer-test-agent to generate unit tests for a specific method in a file.

  • Method 2: Invoke it with a right-click shortcut (supported only on IntelliJ series tools, and only for Java).

    In agent mode, right-click a Java method name and choose CodeArts Agent > Generate Unit Tests (Agent) from the shortcut menu to quickly enable it. For details, see IntelliJ IDEA.

Agent-based Unit Tests

The unit test agent works best with mainstream programming languages such as Java, C, C++, Go, Python, TypeScript, and JavaScript. The following example demonstrates how to perform a unit test by invoking the unit test agent through its name.

  1. Log in to CodeArts Agent as instructed in Quick Start.
  2. In the chat box of CodeArts Agent, change the model to Agent. The selected model is displayed on the right. You can select a model as required from the drop-down list.
  3. Enter a prompt containing the keyword "developer-test-agent" to start the unit test.

    Use developer-test-agent to generate unit tests for the main method in SnakeGame.java.

  4. Check whether a unit test file is generated. If yes, the execution is successful and the test is passed. The figure below is for reference only. The actual file may vary.

    Figure 1 Unit test result