Cover-Agent Project Introduction
Cover-Agent is an innovative project designed to enhance code quality by streamlining the process of test generation, with a focus on unit tests. It leverages the power of Generative AI models to automatically create tests, thus increasing code coverage and ensuring a smoother development process for software engineers. This tool is a part of a larger suite aimed at automating and improving the quality of software development practices.
Overview
The Cover-Agent project consists of several key components that work together to automate the test generation process:
-
Test Runner: Executes commands or scripts designed to run the existing test suite, generating code coverage reports in the process.
-
Coverage Parser: Ensures that each new test contributes to an increase in overall code coverage, validating the effectiveness of the added tests.
-
Prompt Builder: Collects necessary data from the codebase to construct prompts sent to a Large Language Model (LLM). This is crucial for generating relevant and effective tests.
-
AI Caller: Communicates with the LLM to create tests based on the prompts provided, further integrating intelligent automation into the testing workflow.
Installation and Usage
Requirements
To start using Cover-Agent, there are a few prerequisites:
- Environment Variable: You need to set the
OPENAI_API_KEY
in your environment to call the OpenAI API. - Code Coverage Tool: Ensure you have a tool like pytest-cov for generating Cobertura XML code coverage reports.
Additionally, if you're planning to run the tool from the source repository, you will need:
- Python and Poetry: Python must be installed on your system, along with Poetry, a dependency manager for Python projects.
Standalone and Pip Installation
Cover-Agent offers flexibility depending on your setup:
-
Python Pip Package: Install the Cover-Agent as a Python package using the command:
pip install git+https://github.com/Codium-ai/cover-agent.git
-
Standalone Binary: You can also run Cover-Agent as a standalone executable, even in environments without Python, such as Docker containers. Downloads are available on the project’s release page.
Running Cover-Agent
After installation, you can run Cover-Agent using the command line for generating and validating unit tests. Here’s a basic example of how to use it:
cover-agent \
--source-file-path "<path_to_source_file>" \
--test-file-path "<path_to_test_file>" \
--code-coverage-report-path "<path_to_coverage_report>" \
--test-command "<test_command_to_run>" \
--test-command-dir "<directory_to_run_test_command>" \
--coverage-type "<type_of_coverage_report>" \
--desired-coverage <desired_coverage_between_0_and_100> \
--max-iterations <max_number_of_llm_iterations> \
--included-files "<optional_list_of_files_to_include>"
This modular setup allows for detailed customization based on your project needs and desired outcomes.
Development Updates
Cover-Agent continually evolves with significant updates aimed at enhancing functionality and developer experience. Recent updates include:
- Enhanced Database Usage: New capabilities for logging test results.
- Improved Documentation: More comprehensive user examples and configuration templates.
- Multi-Language Support: Docker configurations for languages like C#, TypeScript, and React, providing versatile testing environments.
Conclusion
Cover-Agent represents a major step forward in automated test generation and quality assurance in software development. By continuously expanding its features and improving usability, the Cover-Agent project invites collaboration and community engagement to refine its capabilities and explore new advancements in test automation.