Unit Tests Generation¶
This guide explains how CloudAEye performs automated unit test generation.
Overview¶
CloudAEye assists in generating comprehensive tests for your code, including support for edge cases, aiming for high code coverage, and creating negative test cases. This can be initiated by commenting @cloudaeye /test in your Pull Request (PR) timeline.
Prerequisites¶
To use CloudAEye's test generation features, the following prerequisites must be met:
Step 1: Sign up with CloudAEye SaaS.
Step 2: Setup Code Review by following the Getting Started guide.
Initiate Test Generation¶
To initiate automated test generation for your connected repository, comment @cloudaeye /test in your Pull Request (PR) timeline. CloudAEye will then analyze your code changes and suggest or generate relevant tests.

Example from GitLab environment.

Preferences¶
CloudAEye offers various preferences to customize its test generation behavior, accessible through the CloudAEye UI.
Enable automatic test updates on code change¶
You can configure CloudAEye to automatically update existing tests or generate new ones whenever there are significant code changes in your connected repositories. Enabling this preference ensures that your test suite remains relevant and comprehensive with minimal manual intervention, adapting to evolving codebases.
Support for Test Frameworks in Preferences UI¶
CloudAEye's test generation capabilities support a wide range of popular testing frameworks across different programming languages. In the preferences UI or GitHub Repository mapping UI, you can specify the frameworks relevant to your project, allowing CloudAEye to generate tests compatible with your existing setup.
| Programming Language | Test Frameworks |
|---|---|
| Python | pytest |
| unittest/PyUnit | |
| doctest | |
| nose2 | |
| Hypothesis | |
| JavaScript | Jest |
| Mocha + Chai | |
| Vitest | |
| Jasmine | |
| AVA | |
| TypeScript | Jest |
| Mocha + Chai + ts-node | |
| Vitest | |
| Jasmine | |
| AVA | |
| Java | JUnit |
| TestNG | |
| Mockito | |
| AssertJ | |
| Spock | |
| Go | testing |
| Testify | |
| GoMock | |
| Ginkgo + Gomega | |
| GoConvey | |
| C# | xUnit |
| NUnit | |
| MSTest | |
| Moq | |
| NSubstitute | |
| C++ | Google Test (gtest) |
| Catch2 | |
| doctest | |
| Boost.Test | |
| C | Unity |
| CMocka | |
| Check | |
| Kotlin | JUnit 5 (Jupiter) |
| Kotest | |
| MockK |
If you don't see your programming language or the test framework, please let us know at support@cloudaeye.com.
How Do I Use CloudAEye and Generate Unit Tests in Coding Agent?¶
CloudAEye integrates with AI coding agents in supported IDEs and CLIs to help developers review code changes, generate unit tests, and improve code quality directly within their development workflow.
CloudAEye supports Claude Code, Codex, Cursor, VS Code, PyCharm, and IntelliJ IDEA through its MCP integration. Once installed and configured, you can use CloudAEye to:
- Initialize your repository: Set up CloudAEye for the repository you want to work with and complete authentication when prompted.
- Inspect code changes: Use the
inspectworkflow to identify potential bugs and other code quality issues in your changes. - Analyze security risks: Use the
securityworkflow to identify potential security vulnerabilities in your implementation. - Perform a comprehensive review: Use the
reviewworkflow to conduct a broader review of your code changes. You can also review an eligible open pull request by providing its PR number. - Generate unit tests: Ask your coding agent to use CloudAEye to help generate unit tests for your code. For an existing pull request, use the
/cloudaeye:add-testscommand to identify changed code that lacks test coverage and propose unit tests directly on the PR. - Refine and validate your implementation: Use review findings to guide your coding agent in fixing issues and adding tests. Run the relevant test suite and review the updated changes to validate the implementation.
Generate Unit Tests for a Pull Request from Coding Agent¶
To propose unit tests for an existing pull request:
- Open the repository associated with the pull request in your configured coding agent.
- Run the following command, replacing
412with your pull request number:
/cloudaeye:add-tests #412
- Confirm the operation when prompted. CloudAEye analyzes the pull request changes and proposes unit tests for code that is not adequately covered by existing tests.
- Review the generated test suggestions on the pull request. Where supported, you can apply suggestions directly. Proposed new test files may appear as comments instead.
- Apply the appropriate changes, run your test suite, and verify that the tests pass.
CloudAEye reports the proposed tests and links to the pull request, but it does not execute the generated tests. Review the suggestions and validate them in your development environment.
CloudAEye helps you identify issues earlier, improve test coverage, reduce manual review effort, and maintain code quality as you develop.
For installation instructions, authentication, and IDE-specific configuration, see the IDE Integrations with MCP guide.
For the complete list of coding-agent commands and their usage, see the Coding Agent User Guide.
Use Cases¶
CloudAEye Unit Test Generation helps developers create meaningful tests, improve test coverage, and validate code changes throughout the software development lifecycle.
1. Generate Tests for New Code¶
Generate unit tests for newly implemented functions, classes, and modules without writing every test case manually.
Example: A developer implements a discount calculation function. CloudAEye can generate tests for regular discounts, maximum discounts, and ineligible purchases.
Benefits: - Accelerate test development for new features. - Cover expected behavior and common input scenarios. - Reduce the manual effort required to create initial test suites.
2. Support Edge Cases and Boundary Conditions¶
CloudAEye analyzes code paths and input conditions to generate tests for edge cases that may be overlooked during development. These tests help uncover defects that occur outside normal operating conditions.
Scenarios include:
- Boundary conditions: Minimum and maximum values, empty collections, null values, and boundary limits.
- Invalid inputs: Unexpected data types, malformed values, and unsupported input combinations.
- Concurrency: Potential race conditions and concurrent access issues, where applicable.
- Error handling: Exception paths, failed operations, and recovery behavior.
Example: A pagination function needs to handle empty datasets, page numbers beyond the last page, and invalid page sizes.
Benefits: - Catch boundary-related defects before deployment. - Improve robustness across a wider range of inputs. - Reduce failures caused by unexpected input combinations.
3. Cover Negative Test Cases and Error Handling¶
CloudAEye helps developers test how their applications behave when operations fail or inputs do not meet expectations. Negative test cases verify that errors are handled correctly and that applications fail safely when necessary.
Scenarios include:
- Invalid user input: Empty fields, malformed data, invalid formats, and unsupported values.
- Resource failures: Missing files, unavailable services, network errors, and failed database operations.
- Security-related inputs: Malicious payloads, injection attempts, and inputs designed to bypass validation.
- Limit violations: Exceeded quotas, oversized requests, and values outside supported limits.
- Exception handling: Verifying that expected exceptions are raised, handled, or propagated appropriately.
Example: A file-processing service should handle missing files, permission errors, malformed input, and failed network requests gracefully.
Benefits: - Validate error-handling logic. - Ensure failures are handled predictably. - Strengthen input validation and reduce unexpected application behavior.
4. Improve Line and Branch Coverage¶
CloudAEye helps developers improve unit test coverage by generating tests that exercise code paths that may not be covered by existing tests.
It analyzes source code to identify test scenarios for uncovered statements and branches, helping developers expand their test suites and assess coverage gaps.
Use this capability to:
- Increase line coverage: Generate tests intended to execute previously uncovered lines of code.
- Exercise conditional branches: Cover alternative outcomes of conditional logic.
- Identify coverage gaps: Find areas where additional tests may be needed.
- Support refactoring: Expand test coverage before or during code changes to improve confidence in the implementation.
Example: A legacy service has limited coverage for validation and error-handling logic. CloudAEye can help generate tests for these paths to improve coverage.
Benefits: - Expand coverage without rewriting existing test suites. - Identify untested areas of the codebase. - Improve confidence when maintaining legacy applications.
CloudAEye can help developers work toward high, potentially 100%, line coverage. Actual coverage depends on the code, available test infrastructure, and generated test quality. High line coverage alone does not guarantee that tests will detect defects.
5. Validate AI-Generated Code¶
AI coding agents can generate code quickly, but the resulting implementation may contain incorrect assumptions, missing validations, or unhandled edge cases. Unit tests help validate the expected behavior of AI-generated code.
Example: An AI coding agent generates a user-permission check. Tests can cover authorized users, unauthorized users, missing credentials, and attempts to access another user's data.
Benefits: - Validate AI-generated implementations against expected behavior. - Catch defects before merging generated code. - Support iterative development workflows with AI coding agents.
6. Prevent Regressions in Pull Requests¶
Generate tests for changed code to help verify new functionality and preserve existing behavior.
Example: A pull request changes date-parsing logic. Tests can cover supported date formats, invalid dates, timezone boundaries, and previously supported inputs.
Benefits: - Detect unintended changes in existing behavior. - Improve confidence when reviewing pull requests. - Help developers identify regressions before merging.
7. Follow Existing Testing Frameworks and Conventions¶
Configure the appropriate testing framework so generated tests align with the project's technology stack and existing test conventions.
Example: A Python project uses pytest, while a Java project uses JUnit. Configure the appropriate framework to ensure generated tests follow the project's testing approach.
Benefits: - Maintain consistency with existing test suites. - Reduce the effort required to adapt generated tests. - Simplify integration into established development workflows.
8. Keep Tests Aligned with Code Changes¶
When implementations evolve, existing tests may become outdated or fail to cover new behavior. Use test generation and updates to help keep the test suite aligned with code changes.
Example: A developer changes a function's parameters and return behavior. Updated tests can reflect the new contract while preserving coverage of important existing scenarios.
Benefits: - Keep tests relevant as implementations change. - Reduce maintenance effort for evolving codebases. - Help preserve test coverage during refactoring.
Best Practices¶
- Review generated tests: Verify that test cases and assertions accurately represent the intended behavior.
- Run the tests: Execute generated tests in your project's test environment and resolve any failures.
- Test meaningful behavior: Prioritize assertions that detect incorrect results rather than merely executing code.
- Cover failure scenarios: Include invalid inputs, exceptions, and boundary conditions where appropriate.
- Measure coverage alongside test quality: High line coverage does not necessarily mean tests will detect defects.
- Follow project conventions: Use the appropriate testing framework and adhere to existing naming, fixture, and setup patterns.
CloudAEye helps accelerate unit test creation, but developers remain responsible for validating the generated tests and ensuring they provide meaningful coverage.