Enjinx
  • Enjinx
    • What is Enjinx ?
    • Setup and Installation
      • Install on VSCode
      • Install on JetBrains IDEs
      • Subscription Plans
      • Sign in
      • Extension Settings
      • Uninstall Enjinx
    • Enjinx Chat
      • Focus
        • Current File Focus
        • Git Diff Focus
      • Context
        • Add Context
        • Add image as Context
      • Commands
        • /ask
        • /changelog
        • /commit
        • /describe
        • /docstring
        • /enhance
        • /explain
        • /find-on-github
        • /generate-best-practices
        • /help
        • /improve
        • /issues
        • /quick-test
        • /recap
        • /review
        • /test-suite
      • Chat History
      • Model Selection
      • Company Codebase
    • Code Completion
    • Coding Agent
      • Tasks
      • Continuous Code Improvement
    • Test Generation
      • Using Test Generation
      • Behaviors
      • Test Suite
      • Configuration
      • Example Test
      • Context
      • Running Tests
    • Data Sharing
  • Enjinx cover
    • What is Enjinx Cover ?
    • Setup
      • GitHub Action
      • CLI
    • Feature Flags
    • Database Usage
    • Coverage Report
    • Examples
  • Alpha Codium
    • What is Alpha Codium?
    • Setup
    • Usage
      • Configuration
      • Solving Problems
      • Solving the entire dataset
      • Evaluation
    • Technical Q&A
    • Research Paper
    • Examples
Powered by GitBook
On this page
  1. Enjinx cover

Examples

These examples attempt to add more tests for the code written in the Enjinx 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.

Copy

Copy

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:

Copy

Copy

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.

Copy

Copy

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.

Copy

Copy

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
PreviousCoverage ReportNextWhat is Alpha Codium?

Last updated 5 months ago