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: Register¶
Sign up with CloudAEye SaaS.
Step 2: Install GitHub App¶
Integrate with GitHub by installing the GitHub app.
Step 3: Connect Github Repositories¶
Connect the repositories where you would like to use CloudAEye generate tests.
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.
Support for Edge Cases¶
CloudAEye's test generation capability focuses on identifying and covering potential edge cases within your code. It analyzes inputs and logic paths to create tests that push the boundaries of normal operation, helping uncover subtle bugs that might otherwise be missed. This includes handling:
- Boundary conditions (e.g., minimum/maximum values, empty inputs, nulls)
- Invalid or unexpected inputs
- Concurrency issues
- Error handling paths
Covering 100% Line Coverage¶
CloudAEye aims to help you achieve high, if not 100%, line coverage for your code. Through intelligent analysis of your source code, CloudAEye generates tests designed to execute every line of code, ensuring that all parts of your application are exercised by the test suite. This feature provides a clear report on areas lacking coverage and suggests new tests to fill those gaps.
Covering Negative Test Cases¶
Beyond typical successful execution paths, CloudAEye also focuses on generating negative test cases. These tests validate how your application behaves under abnormal or erroneous conditions, such as:
- Invalid user input
- Resource unavailability (e.g., file not found, network error simulation)
- Security vulnerabilities (e.g., injection attempts)
- Exceeding limits or quotas CloudAEye identifies scenarios where errors or exceptions are expected and creates tests to confirm that your application handles them gracefully and securely.
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.
-
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
How Do I Use the IDE Plugin to Generate Unit Tests?¶
CloudAEye provides an IDE plugin for VSCode designed to streamline the unit test generation process directly within your development environment. Once installed and configured, the plugin integrates with your IDE to:
-
Analyze Code: Select a function, class, or module within your code editor.
-
Generate Suggestions: The plugin leverages CloudAEye's AI to suggest relevant unit tests based on the selected code's logic, inputs, and potential edge cases.
-
Preview and Insert: Review the generated test code directly in your IDE. You can then insert the test code into your existing test files or create new ones with a single click.
- Refine and Run: Modify the generated tests as needed and run them using your preferred test runner within the IDE. This direct integration significantly reduces the time and effort required to create robust unit tests, allowing you to maintain high code quality as you develop.
Refer to VS Code: Generate Unit Tests page to learn more.