Skip to content

feat: add mutation testing with mutation_test package#39

Merged
grunch merged 5 commits into
mainfrom
feat/mutation-testing
Mar 3, 2026
Merged

feat: add mutation testing with mutation_test package#39
grunch merged 5 commits into
mainfrom
feat/mutation-testing

Conversation

@mostronatorcoder

@mostronatorcoder mostronatorcoder Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds mutation testing infrastructure to Choke using the mutation_test package (v1.8.0+), the only actively maintained mutation testing tool for Dart/Flutter.

Closes #37

What's included

1. mutation_test.xml — Configuration

  • Targets lib/features/match/models/ (the module with the most comprehensive tests)
  • Uses flutter test as the test command (120s timeout)
  • Excludes non-testable lines (imports, comments, annotations, closing braces)
  • Quality thresholds: A (>80%) through E (>0%), with failure="0" (report-only mode)

2. docs/ci/mutation-testing.yaml — CI Workflow Template

Two jobs:

  • mutation-test: Full baseline on pushes to main + weekly Monday 6:00 UTC
  • mutation-test-pr: Incremental — only mutates changed source files on PRs

Both are non-blocking (continue-on-error: true). Reports uploaded as artifacts.

Note: The GitHub App cannot push workflow files. Copy docs/ci/mutation-testing.yaml to .github/workflows/mutation-testing.yaml to activate.

3. docs/MUTATION_TESTING.md — Usage Guide

  • How to run locally (full, single file, incremental, with coverage)
  • How to interpret reports and fix surviving mutants
  • Configuration reference
  • Quality rating scale

4. pubspec.yaml — Dependency

Added mutation_test: ^1.8.0 to dev_dependencies.

How to use

# Install
flutter pub get

# Run mutation tests on configured files
dart run mutation_test mutation_test.xml

# Run on a single file
dart run mutation_test lib/features/match/models/match.dart

# Run only on files changed since last commit
dart run mutation_test $(git diff --name-only HEAD~1 -- 'lib/**.dart' | grep -v '_test.dart$' | tr '\n' ' ')

# Speed up with coverage data
flutter test --coverage
dart run mutation_test mutation_test.xml --coverage coverage/lcov.info

Reports are generated as HTML in mutation-test-report/ (gitignored).

Why mutation_test?

Tool Status Dart support
mutation_test ✅ Active (v1.8.0, Feb 2026) Native Dart, works with Flutter
DCM ❌ No mutation testing feature Linting/metrics only
StrykerJS ❌ No Dart support JS/TS only

Next steps

  1. Run baseline to establish current mutation score
  2. Add more directories to mutation_test.xml as test coverage grows
  3. Set failure threshold once baseline is stable
  4. Copy CI workflow to .github/workflows/

Summary by CodeRabbit

  • Documentation

    • Added mutation testing documentation with guidance on running tests, configuration, and result interpretation.
  • Chores

    • Set up automated mutation testing in CI/CD pipeline for main branch and pull requests.
    • Added mutation testing tooling and configuration.

Add mutation testing infrastructure to evaluate test suite quality:

- Add mutation_test ^1.8.0 to dev_dependencies
- Create mutation_test.xml configuration targeting match models
- Add docs/ci/mutation-testing.yaml (CI workflow template — copy to
  .github/workflows/ to activate)
- Add docs/MUTATION_TESTING.md with usage guide
- Add mutation-test-report/ to .gitignore

The mutation testing starts with lib/features/match/models/ which has
the most comprehensive tests. As test coverage grows, more directories
can be added to the configuration.

CI jobs are non-blocking initially (continue-on-error: true). Set the
failure threshold in mutation_test.xml once a baseline is established.

Note: The GitHub App cannot push workflow files directly. The CI
workflow is provided in docs/ci/ and must be manually copied to
.github/workflows/ by a maintainer.

Closes #37
Use pattern attribute on <regex> elements as required by mutation_test
package. Fix widget tests to wrap ChokeApp in ProviderScope and update
match status expectations to use kebab-case serialization format.
@grunch

grunch commented Mar 3, 2026

Copy link
Copy Markdown
Owner

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Mar 3, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Mar 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR introduces comprehensive mutation testing infrastructure to evaluate test suite quality. It adds configuration files (mutation_test.xml, GitHub Actions workflow), documentation, a dart mutation_test dev dependency, updates .gitignore, and adjusts test expectations to align with new JSON serialization formats.

Changes

Cohort / File(s) Summary
CI Workflow Setup
docs/ci/mutation-testing.yaml
Introduces GitHub Actions workflow with two jobs: mutation-test (runs on main branch push, weekly schedule, and manual dispatch) and mutation-test-pr (runs on pull requests with smart file change detection). Includes artifact uploads with configurable retention periods.
Mutation Testing Configuration
mutation_test.xml
Adds mutation testing configuration targeting lib/features/match/models/, specifying flutter test command with 120s timeout, exclusion patterns for imports/decorators/comments, and quality threshold tiers (A–E rating system).
Documentation & Gitignore
docs/MUTATION_TESTING.md, .gitignore
Adds comprehensive mutation testing guide covering concepts, tooling, running scenarios, report layout, and CI integration. Appends mutation-test-report/ to .gitignore.
Dependencies
pubspec.yaml
Adds mutation_test: ^1.8.0 to dev_dependencies.
Test Updates
test/features/match/models/match_test.dart, test/widget_test.dart
Updates MatchStatus JSON serialization expectations from 'inProgress' to 'in-progress'. Wraps app widget with Riverpod ProviderScope. Updates test expectation text and comment wording.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #20: Related to MatchStatus JSON serialization format changes reflected in the test updates.

Poem

🐰 Mutations dance through lib/ so bright,
Test suite guards the code at night,
If bugs creep in, the tests will see,
A stronger codebase, wild and free!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes changes to test expectations (MatchStatus serialization format and widget test text) that are beyond the scope of adding mutation testing infrastructure. Move test expectation updates to a separate PR focused on test fixes, or clearly document why these changes are necessary as part of the mutation testing setup.
Linked Issues check ❓ Inconclusive The PR implements mutation testing but uses mutation_test package instead of DCM as specified in issue #37; this deviation warrants clarification on whether the alternative tool meets the stated objectives. Confirm that mutation_test v1.8.0 provides equivalent mutation testing capabilities and CI integration compared to DCM, or clarify the rationale for the tool choice in the PR description.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: add mutation testing with mutation_test package' accurately summarizes the main change: integrating mutation testing tooling into the project.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/mutation-testing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/ci/mutation-testing.yaml`:
- Around line 3-10: The workflow is missing a pull_request trigger so the job
mutation-test-pr (which guards with if: github.event_name == 'pull_request') is
never executed; update the workflow's on: block to include a pull_request
trigger (restrict to same branches as push, e.g., branches: [main]) so PR events
will run the workflow and make the mutation-test-pr job reachable.

In `@docs/MUTATION_TESTING.md`:
- Around line 53-57: Update the docs/MUTATION_TESTING.md text to explicitly
instruct readers to copy the workflow template from docs/ci/ into the repository
workflows folder so it becomes active: add a step telling users to copy or move
the file (e.g., "copy docs/ci/mutation-testing.yaml to
.github/workflows/mutation-testing.yaml") and mention that the workflow will
only run once placed under .github/workflows/, referencing the workflow name
`.github/workflows/mutation-testing.yaml` so it's clear the file in docs/ci/ is
a template not the active workflow.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2fef901 and 152538e.

📒 Files selected for processing (7)
  • .gitignore
  • docs/MUTATION_TESTING.md
  • docs/ci/mutation-testing.yaml
  • mutation_test.xml
  • pubspec.yaml
  • test/features/match/models/match_test.dart
  • test/widget_test.dart

Comment on lines +3 to +10
on:
push:
branches: [main]
schedule:
# Weekly on Monday 6:00 UTC
- cron: '0 6 * * 1'
workflow_dispatch:

@coderabbitai coderabbitai Bot Mar 3, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="docs/ci/mutation-testing.yaml"

# Check if file exists
if [ ! -f "$FILE" ]; then
    echo "File not found: $FILE"
    exit 1
fi

echo "=== File: docs/ci/mutation-testing.yaml ==="
echo
echo "=== Lines 1-20 (trigger block) ==="
head -20 "$FILE"

echo
echo "=== Lines 40-55 (checking for PR job guard) ==="
sed -n '40,55p' "$FILE"

echo
echo "=== Checking for pull_request trigger ==="
if grep -n "pull_request:" "$FILE"; then
    echo "✓ pull_request trigger FOUND"
else
    echo "✗ pull_request trigger NOT FOUND"
fi

echo
echo "=== Checking for PR-gated job ==="
grep -n "if:.*pull_request" "$FILE" || true

Repository: grunch/choke

Length of output: 1070


Add pull_request trigger — mutation-test-pr job is unreachable.

The workflow defines a mutation-test-pr job at line 47 with if: github.event_name == 'pull_request', but the trigger block (lines 3–10) lacks a pull_request trigger. The workflow will never run on PRs, making that job unreachable dead code.

🔧 Proposed fix
 on:
   push:
     branches: [main]
+  pull_request:
+    branches: [main]
   schedule:
     # Weekly on Monday 6:00 UTC
     - cron: '0 6 * * 1'
   workflow_dispatch:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
on:
push:
branches: [main]
schedule:
# Weekly on Monday 6:00 UTC
- cron: '0 6 * * 1'
workflow_dispatch:
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
# Weekly on Monday 6:00 UTC
- cron: '0 6 * * 1'
workflow_dispatch:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/ci/mutation-testing.yaml` around lines 3 - 10, The workflow is missing a
pull_request trigger so the job mutation-test-pr (which guards with if:
github.event_name == 'pull_request') is never executed; update the workflow's
on: block to include a pull_request trigger (restrict to same branches as push,
e.g., branches: [main]) so PR events will run the workflow and make the
mutation-test-pr job reachable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderabbitai[bot] Resolved in commit 75de743. ✅

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipped: comment is from another GitHub bot.

Comment thread docs/MUTATION_TESTING.md Outdated
Comment on lines +53 to +57
The GitHub Actions workflow (`.github/workflows/mutation-testing.yaml`) runs:

1. **Full baseline** on pushes to `main` and weekly (Monday 6:00 UTC)
2. **Incremental** on PRs (only changed source files)

@coderabbitai coderabbitai Bot Mar 3, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify activation step for the workflow path.

This section implies the workflow is already active at .github/workflows/..., but the file introduced here is under docs/ci/. Add an explicit “copy template to .github/workflows/” step to avoid confusion.

📝 Suggested wording tweak
- The GitHub Actions workflow (`.github/workflows/mutation-testing.yaml`) runs:
+ After copying `docs/ci/mutation-testing.yaml` to `.github/workflows/mutation-testing.yaml`,
+ the GitHub Actions workflow runs:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
The GitHub Actions workflow (`.github/workflows/mutation-testing.yaml`) runs:
1. **Full baseline** on pushes to `main` and weekly (Monday 6:00 UTC)
2. **Incremental** on PRs (only changed source files)
After copying `docs/ci/mutation-testing.yaml` to `.github/workflows/mutation-testing.yaml`,
the GitHub Actions workflow runs:
1. **Full baseline** on pushes to `main` and weekly (Monday 6:00 UTC)
2. **Incremental** on PRs (only changed source files)
🧰 Tools
🪛 LanguageTool

[uncategorized] ~53-~53: The official name of this software platform is spelled with a capital “H”.
Context: ...tegration The GitHub Actions workflow (.github/workflows/mutation-testing.yaml) runs:...

(GITHUB)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/MUTATION_TESTING.md` around lines 53 - 57, Update the
docs/MUTATION_TESTING.md text to explicitly instruct readers to copy the
workflow template from docs/ci/ into the repository workflows folder so it
becomes active: add a step telling users to copy or move the file (e.g., "copy
docs/ci/mutation-testing.yaml to .github/workflows/mutation-testing.yaml") and
mention that the workflow will only run once placed under .github/workflows/,
referencing the workflow name `.github/workflows/mutation-testing.yaml` so it's
clear the file in docs/ci/ is a template not the active workflow.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderabbitai[bot] Resolved in commit 75de743. ✅

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipped: comment is from another GitHub bot.

- docs/ci/mutation-testing.yaml: Add pull_request trigger for mutation-test-pr job
- docs/MUTATION_TESTING.md: Clarify that template must be copied to .github/workflows/
- Fixes CodeRabbit review comments on PR #39

@mostronatorcoder mostronatorcoder Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 75de743. @coderabbitai[bot] marking this as resolved.

@mostronatorcoder mostronatorcoder Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 75de743. @coderabbitai[bot] marking this as resolved.

@mostronatorcoder mostronatorcoder Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 75de743. @coderabbitai[bot] marking this as resolved.

Changes Made:

  1. Added pull_request trigger to docs/ci/mutation-testing.yaml
  2. Clarified workflow activation in `docs/MUTATION_TESTING.md

grunch added 2 commits March 3, 2026 15:19
- Change from 'open' command only to explicit commands for all OS
- Add note about manual browser opening as alternative
- Change index.html to mutation-test-report.html (actual filename)

@grunch grunch left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

@grunch grunch merged commit 542e857 into main Mar 3, 2026
1 check passed
@grunch grunch deleted the feat/mutation-testing branch March 3, 2026 15:32
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.

Add mutation testing with DCM to evaluate test suite quality

1 participant