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.
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.