Skip to main content

Module coverage

Module coverage 

Source
Expand description

§Test Coverage Analysis System

Enterprise-grade test coverage analysis with comprehensive tracking of code coverage, branch coverage, and integration coverage for production-level quality assurance. Provides detailed insights into test effectiveness and identifies uncovered code paths.

§Features

  • Code Coverage: Line-by-line execution tracking with detailed statistics
  • Branch Coverage: Decision point analysis for conditional statements
  • Integration Coverage: Cross-module and cross-component coverage tracking
  • Coverage Visualization: HTML reports, charts, and interactive coverage maps
  • Historical Tracking: Coverage trends and regression analysis over time
  • Quality Gates: Configurable coverage thresholds and pass/fail criteria
  • Differential Coverage: Coverage analysis for code changes and pull requests
  • Multi-format Reports: JSON, XML, LCOV, and HTML output formats
  • Real-time Monitoring: Live coverage updates during test execution
  • Performance Impact: Low-overhead instrumentation for production environments

§Example

use scirs2_core::profiling::coverage::{
    CoverageAnalyzer, CoverageConfig, CoverageType, ReportFormat
};

// Create coverage analyzer
let config = CoverageConfig::production()
    .with_coverage_types(vec![
        CoverageType::Line,
        CoverageType::Branch,
        CoverageType::Integration
    ])
    .with_threshold(80.0)
    .with_report_format(ReportFormat::Html);

let mut analyzer = CoverageAnalyzer::new(config)?;

// Start coverage collection
analyzer.start_collection()?;

// Run your tests here...
fn run_test_suite() {
    // Example test function that would run the actual test suite
    println!("Running test suite...");
}
run_test_suite();

// Stop collection and generate report
let report = analyzer.stop_and_generate_report()?;
println!("Overall coverage: {:.2}%", report.overall_coverage_percentage());

// Check if coverage meets thresholds
if report.meets_quality_gates() {
    println!("✅ Coverage quality gates passed!");
} else {
    println!("❌ Coverage below threshold");
}

Structs§

BranchCoverage
Branch coverage information
CoverageAnalyzer
Main coverage analyzer
CoverageConfig
Coverage configuration
CoverageDataPoint
Historical coverage data point
CoverageRecommendation
Coverage improvement recommendations
CoverageReport
Overall coverage report
CoverageStatistics
Coverage statistics
CoverageTrends
Coverage trends over time
FileCoverage
Coverage data for a single source file
FunctionCoverage
Function coverage information
IntegrationPoint
Integration coverage point
PerformanceImpact
Performance impact of coverage collection
QualityGateFailure
Quality gate failure details
QualityGateResults
Quality gate results

Enums§

BranchType
Types of branches
CollectionState
Coverage collection state
CoverageType
Types of coverage analysis
FailureSeverity
Failure severity levels
IntegrationType
Types of integration points
RecommendationPriority
Recommendation priority levels
RecommendationType
Types of coverage recommendations
ReportFormat
Report output formats
TrendDirection
Trend direction