Examples of Qodo Cover

These examples attempt to add more tests for the code written in the Qodo Cover repository. In order to properly run them you will need to set up your development environment by running poetry install.

Running a folder, and targeting a specific file inside it

In this example, we execute the tests/test_PromptBuilder.py file to test the entire cover_agent folder. However, during post-processing, we focus on extracting the coverage data specifically for the PromptBuilder.py file. This means that while the whole folder is tested, our primary interest is in the coverage results for PromptBuilder.py.

cover-agent \
--model "gpt-4o" \
--source-file-path "cover_agent/PromptBuilder.py" \
--test-file-path "tests/test_PromptBuilder.py" \
--code-coverage-report-path "coverage.xml" \
--test-command "poetry run pytest tests/test_PromptBuilder.py --cov=cover_agent --cov-report=xml --cov-report=term --log-cli-level=INFO --timeout=10" \
--coverage-type "cobertura" \
--desired-coverage 90 \
--max-iterations 5

Running only on a specific module

In this example, we run the tests/test_PromptBuilder.py file only on the PromptBuilder module, using a more elaborate test command:

cover-agent \
--model="gpt-4o" \
--source-file-path "cover_agent/PromptBuilder.py" \
--test-file-path "tests/test_PromptBuilder.py" \
--code-coverage-report-path "tests/coverage_prompt_builder.xml" \
--test-command "poetry run  pytest --cov=cover_agent.PromptBuilder --cov-report=xml:tests/coverage_prompt_builder.xml --cov-report=term tests/test_PromptBuilder.py --timeout=10" \
--coverage-type "cobertura" \
--desired-coverage 90 \
--max-iterations 5

Utilizing additional instructions

For test files containing multiple classes, the AI model might not know which class to focus on. To address this, you can use the --additional-instructions flag to guide the model.

cover-agent \
--model="gpt-4o" \
--source-file-path "cover_agent/UnitTestGenerator.py" \
--test-file-path "tests/test_UnitTestGenerator.py" \
--code-coverage-report-path "coverage.xml" \
--test-command "poetry run pytest tests/test_UnitTestGenerator.py --cov=cover_agent --cov-report=xml --cov-report=term --log-cli-level=INFO --timeout=5" \
--coverage-type "cobertura" \
--desired-coverage 90 \
--max-iterations 5 \
--additional-instructions="add tests to the class 'TestUnitTestGenerator'"

Adding extra context files

In some cases, the AI model may require additional context to understand the code better, in addition to the source and test file. Utilize the --included-files flag to provide additional context files to the model.

cover-agent \
--model="gpt-4o" \
--source-file-path "cover_agent/main.py" \
--test-file-path "tests/test_main.py" \
--included-files "cover_agent/CoverAgent.py" \
--code-coverage-report-path "coverage.xml" \
--test-command "poetry run pytest tests/test_main.py --cov=cover_agent --cov-report=xml --cov-report=term --log-cli-level=INFO --timeout=10" \
--coverage-type "cobertura" \
--desired-coverage 96 \
--max-iterations  8

Last updated

Logo

2025 Qodo. All Rights Reserved.