Skip to content

Add test coverage reporting support #27

@jbrinkman

Description

@jbrinkman

Summary

Add support for generating and viewing test coverage reports for the C# Valkey GLIDE client to improve code quality and ensure comprehensive test coverage.

Background

Currently, the project has unit tests and integration tests, but there's no automated way to generate test coverage reports. This makes it difficult to:

  • Identify untested code paths
  • Ensure new features have adequate test coverage
  • Track coverage trends over time
  • Meet quality gates for code coverage

Proposed Solution

Implement test coverage reporting using .NET's built-in coverage tools and integrate with the existing build pipeline.

Implementation Details

  1. Add coverage collection to test commands

    • Use dotnet test --collect:"XPlat Code Coverage" for cross-platform coverage
  2. Coverage report generation

    • Use reportgenerator tool to convert coverage data to human-readable formats
    • Generate both summary and detailed coverage reports
  3. Build integration

    • Add coverage collection to existing build scripts
    • Create new build targets for coverage-specific builds
    • Ensure coverage works with both net6.0 and net8.0 targets
  4. CI/CD integration (optional)

    • Integrate coverage reporting into GitHub Actions workflows

Example Implementation

# Collect coverage data
dotnet test --framework net8.0 --collect:"XPlat Code Coverage" --results-directory ./coverage

# Generate HTML report
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:"./coverage/**/coverage.cobertura.xml" -targetdir:"./coverage/report" -reporttypes:Html

Acceptance Criteria

  • Coverage data can be collected for unit tests
  • Coverage data can be collected for integration tests
  • HTML coverage reports can be generated
  • Coverage reports show line and branch coverage
  • Coverage collection works with both net6.0 and net8.0 frameworks
  • Coverage collection doesn't significantly impact test execution time

Additional Considerations

  • Performance: Ensure coverage collection doesn't slow down regular development workflows
  • Exclusions: Configure appropriate exclusions for generated code, test utilities, etc.
  • Thresholds: Consider setting minimum coverage thresholds for different project areas
  • Integration: Consider integration with code quality tools and IDE support

Related Work

This enhancement would complement the existing test infrastructure and support the ongoing development of comprehensive test suites for new features like AZ affinity support.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions