moq.analyzers icon indicating copy to clipboard operation
moq.analyzers copied to clipboard

Add unit tests for PerfDiff core infrastructure (BenchmarkFileReader & Data Contracts)

Open coderabbitai[bot] opened this issue 3 months ago • 0 comments
trafficstars

Overview

This issue covers testing the foundational components of PerfDiff that handle file I/O and data modeling.

Scope

Components to Test

  • BenchmarkFileReader - JSON file reading and deserialization
  • Data Contracts - All model classes in BDN/DataContracts/
    • BdnResult, BdnResults, Benchmark, BdnComparisonResult
    • Statistics, Percentiles, Memory, Measurement
    • HostEnvironmentInfo, ConfidenceInterval, ChronometerFrequency
    • BenchmarkComparisonResult, RegressionResult

Test Scenarios

  1. Valid File Reading

    • Successfully read valid BenchmarkDotNet JSON files
    • Correct deserialization of all properties
    • Handle multiple files in parallel
  2. Error Scenarios

    • File not found
    • Invalid JSON format
    • Missing required properties
    • Empty files
    • Permission denied
  3. Data Contract Validation

    • Property getters/setters work correctly
    • Record types behave as expected
    • Nullable properties handle null values
    • ToString() methods (where implemented)

Test Data Requirements

  • Create sample valid BenchmarkDotNet JSON files
  • Create malformed JSON files for error testing
  • Represent various benchmark scenarios (different metrics, memory usage, etc.)

Acceptance Criteria

  • [ ] BenchmarkFileReader has 100% test coverage
  • [ ] All data contracts have basic property tests
  • [ ] Error handling scenarios are thoroughly tested
  • [ ] Sample test data files are created and committed
  • [ ] Tests follow xUnit patterns used in the repository
  • [ ] All tests pass and run efficiently

Implementation Notes

  • Place tests in tests/PerfDiff.Tests/ (new test project)
  • Use xUnit testing framework
  • Follow existing test patterns in tests/Moq.Analyzers.Test/
  • Mock file system operations where appropriate
  • Use Theory and InlineData for data-driven tests

Related

  • Parent issue: #[MAIN_ISSUE_NUMBER]
  • Components: src/tools/PerfDiff/BDN/BenchmarkFileReader.cs, src/tools/PerfDiff/BDN/DataContracts/

coderabbitai[bot] avatar Jul 23 '25 03:07 coderabbitai[bot]