Skip to content

Conversation

@meylis1998
Copy link
Contributor

Summary

Implements feature request #418 to add a --collect-coverage-from option that allows users to choose whether coverage is collected from imported files only or all files in the project.

Changes

  • Added CoverageCollectionMode enum with imports (default) and all modes
  • Added --collect-coverage-from option to both Flutter and Dart test commands
  • Implemented file discovery and LCOV enhancement to include untested files with 0% coverage
  • Respects existing --exclude-coverage and --report-on options
  • Updated tests to verify functionality

Usage Examples

# Default behavior (unchanged - imports only)
very_good test --coverage

# Include all files in coverage
very_good test --coverage --collect-coverage-from all

# Enforce 100% coverage across all files
very_good test --min-coverage 100 --collect-coverage-from all

# Exclude generated files from coverage
very_good test --coverage --collect-coverage-from all --exclude-coverage '**/*.g.dart'

Key Features

  • ✅ Backward compatible (defaults to imports mode)
  • ✅ Works with both Flutter and Dart projects
  • ✅ Includes all .dart files in 'all' mode, showing 0% for untested files
  • ✅ Compatible with existing coverage options
  • ✅ Respects glob patterns from --exclude-coverage

Files Modified

  • lib/src/cli/test_cli_runner.dart - Core implementation
  • lib/src/commands/test/test.dart - Flutter test command
  • lib/src/commands/dart/commands/dart_test_command.dart - Dart test command
  • lib/src/cli/flutter_cli.dart - Flutter CLI integration
  • lib/src/cli/dart_cli.dart - Dart CLI integration
  • test/src/commands/test/test_test.dart - Flutter test updates
  • test/src/commands/dart/commands/dart_test_test.dart - Dart test updates

Closes #418

@meylis1998 meylis1998 requested a review from a team as a code owner January 23, 2026 14:54
@meylis1998 meylis1998 force-pushed the feat/collect-coverage-from branch 9 times, most recently from 4485b0f to 0aff007 Compare January 23, 2026 21:26
@meylis1998 meylis1998 force-pushed the feat/collect-coverage-from branch from 68fc1f2 to 7e22015 Compare January 24, 2026 10:20
LCOV format expects Unix-style forward slashes in file paths.
On Windows, p.relative() returns backslash-separated paths,
causing test failures when comparing LCOV output.
@meylis1998
Copy link
Contributor Author

meylis1998 commented Jan 24, 2026

Hey @marcossevilla! 👋

When you get a chance, would you mind taking a look at this PR? I'd really appreciate your feedback.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(test): support capturing coverage from all files

1 participant