Skip to content

Daily Test Coverage Improver: Research and Plan #1557

Description

@github-actions

Daily Test Coverage Improver: Research and Plan

Repository Analysis

FSharp.Data is a comprehensive F# type provider library for structured data access (CSV, HTML, JSON, XML) and WorldBank data. The library is well-structured with excellent existing test coverage.

Project Structure

  • Source: 9 core modules in src/ covering CSV, HTML, JSON, XML, HTTP, Runtime Utilities, WorldBank, and DesignTime components
  • Tests: 5 test projects with 3,124 total tests (2,393 Core.Tests + 484 DesignTime.Tests + 247 main Tests)
  • Build: Uses Paket + Fake build system with dotnet run --project build/build.fsproj -- -t Build
  • Coverage: Uses .NET's built-in coverage collection, though F# assembly coverage data isn't being captured properly

Testing Strategy Analysis

Strengths:

  • Comprehensive type provider signature tests (expected/*.expected files)
  • Good coverage of core data parsing functionality
  • Property-based tests for JSON parsing
  • C# interop tests in separate project

Areas Identified for Test Coverage Improvement

Based on source code analysis and existing test gaps:

1. CSV Extension Methods - Missing Tests

  • StringExtensions.AsTimeSpan() - No CSV-specific tests found
  • StringExtensions.AsDateTimeOffset() - No CSV-specific tests found
  • Error handling for invalid date/time strings in CSV context
  • Culture-specific parsing edge cases

2. Caching Infrastructure - Minimal Test Coverage

  • FSharp.Data.Runtime.Caching module has limited dedicated testing
  • In-memory cache expiration behavior
  • File system cache scenarios
  • Cache invalidation edge cases
  • Concurrent access patterns

3. Error Handling & Edge Cases

  • Network timeout scenarios in HTTP module
  • Malformed data recovery in parsers
  • Memory usage with very large datasets
  • Unicode and encoding edge cases

4. Runtime Utilities

  • Pluralizer module functionality
  • NameUtils helper functions
  • File I/O error scenarios in IO.fs

Implementation Plan

Phase 1: CSV Extension Methods Testing

  • Add comprehensive tests for AsTimeSpan and AsDateTimeOffset in CSV context
  • Test error conditions and culture-specific behaviors
  • Verify integration with CsvRow dynamic operator

Phase 2: Caching System Tests

  • Unit tests for in-memory cache behavior
  • Cache expiration and invalidation scenarios
  • Concurrent access testing

Phase 3: Edge Case & Error Handling

  • Network failure simulation tests
  • Large dataset handling verification
  • Unicode/encoding robustness tests

Build & Coverage Commands

# Build
dotnet run --project build/build.fsproj -- -t Build

# Run tests with coverage
dotnet test tests/FSharp.Data.Core.Tests/FSharp.Data.Core.Tests.fsproj --configuration Release --collect:"Code Coverage"

# Format code  
dotnet run --project build/build.fsproj -t Format

Test Organization Strategy

  • Follow existing patterns in each test project
  • Use NUnit framework with FsUnit assertions
  • Maintain separation between unit tests (Core.Tests) and type provider tests (DesignTime.Tests)
  • Add data files to tests/*/Data/ directories as needed

Next Steps

I will focus on implementing the identified improvements, starting with CSV extension methods as they have the clearest test gaps and will provide immediate value to users working with date/time data in CSV files.

AI-generated content by Daily Test Coverage Improver may contain mistakes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions