Updated on 2026-07-30 GMT+08:00

Unit Test (Agent)

The Unit Test (Agent) is an end-to-end test case generation agent that provides core capabilities throughout the entire process, including 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.

Built-in Agents

Agents are programming assistants tailored for diverse development scenarios. CodeArts Agent provides multiple out-of-the-box agents that require no manual creation, aiming to provide efficient programming assistance for various development scenarios. For more information, see Built-in Agents.

Table 1 Built-in sub-agents

Name

Description

general

A general-purpose agent used to research complex problems and execute multi-step tasks.

explore

A code repository exploration agent dedicated to quickly locating files, searching code keywords, and answering related questions.

spec-task-agent

An agent used to generate implementation tasks based on requirements and design.

spec-requirement-agent

An agent used to generate requirements for the Easy Approach to Requirements Syntax (EARS) format based on the project description and context.

spec-design-agent

An agent used to generate comprehensive technical designs, converting requirements (what to do) into architectures (how to do it).

developer-test-agent

An agent dedicated to unit test generation, repair, coverage optimization, and review.

It can be invoked using either of the following methods:

  • Commands: Enter a command directly into the chat box to invoke it. For example, use developer-test-agent to generate a unit test for a specific method in a specific file.
  • Right-click shortcut: This method is only available for IntelliJ IDEA and Java-based unit tests.

    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.

Agent-based Unit Test Generation

  1. Log in to CodeArts Agent as instructed in JetBrains.
  2. On the IntelliJ IDEA sidebar, click the CodeArts Agent icon to open the chat panel.
  3. In the chat box, 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.
  4. Select a code snippet and send a unit test generation command to CodeArts Agent. It can be invoked using either of the following methods:

    • Prompts: Enter a prompt directly into the chat box to invoke it, for example, "Use developer-test-agent to generate a unit test for the main method in the Dijkstra.java file."
      Figure 1 Unit test
    • Right-click shortcut: This method is only available for IntelliJ IDEA of the JetBrains series. 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.
      Figure 2 Choosing Generate Unit Tests (Agent)

  5. Check whether a unit test file is generated. If yes, the execution is successful and the test is passed.