Skip to content

Commit b670921

Browse files
CopilotBurgyn
andauthored
Add Stryker.NET mutation testing configuration and CI workflow
Agent-Logs-Url: https://github.com/Kros-sk/TeaPie/sessions/06690327-20a3-4c5b-a653-d6c40201601d Co-authored-by: Burgyn <5930822+Burgyn@users.noreply.github.com>
1 parent 721f366 commit b670921

5 files changed

Lines changed: 119 additions & 0 deletions

File tree

.config/dotnet-tools.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-stryker": {
6+
"version": "4.14.0",
7+
"commands": [
8+
"dotnet-stryker"
9+
],
10+
"rollForward": false
11+
}
12+
}
13+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Mutation Testing
2+
3+
on:
4+
schedule:
5+
- cron: '0 3 * * 1' # Every Monday at 03:00 UTC
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
mutation-testing:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 60
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup .NET
21+
uses: actions/setup-dotnet@v3
22+
with:
23+
dotnet-version: '8.x'
24+
25+
- name: Restore tools
26+
run: dotnet tool restore
27+
28+
- name: Install dependencies
29+
run: dotnet restore
30+
31+
- name: Run Stryker mutation testing
32+
run: dotnet stryker
33+
34+
- name: Upload mutation report
35+
if: always()
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: mutation-report
39+
path: '**/StrykerOutput/**/reports/**'
40+
retention-days: 14

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,9 @@ FodyWeavers.xsd
401401
**/.teapie/cache/
402402
**/.teapie/reports/
403403

404+
# Stryker mutation testing
405+
**/StrykerOutput/
406+
404407
# User-defined
405408
*launchSettings*.json
406409
docs/_site

docs/mutation-testing.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Mutation Testing
2+
3+
TeaPie uses [Stryker.NET](https://stryker-mutator.io/docs/stryker-net/introduction/) for mutation testing to verify the effectiveness of the test suite.
4+
5+
## Overview
6+
7+
Mutation testing systematically introduces small changes (*mutants*) into the source code and checks whether the existing tests detect them. A killed mutant means the tests caught the change; a surviving mutant may indicate a gap in test assertions.
8+
9+
## Quick Start
10+
11+
```bash
12+
# Restore the local tool
13+
dotnet tool restore
14+
15+
# Run mutation testing
16+
dotnet stryker
17+
```
18+
19+
The HTML report is generated in the `StrykerOutput/` directory.
20+
21+
## Configuration
22+
23+
Stryker is configured via [`stryker-config.json`](../stryker-config.json) in the repository root. Key settings:
24+
25+
| Setting | Value | Description |
26+
|---------|-------|-------------|
27+
| `project` | `TeaPie.csproj` | Source project under test |
28+
| `test-projects` | `TeaPie.Tests.csproj` | Test project |
29+
| `reporters` | html, progress, cleartext | Output formats |
30+
| `thresholds.high` | 80 | Score above this is green |
31+
| `thresholds.low` | 60 | Score below this is red |
32+
33+
## CI Integration
34+
35+
Mutation testing runs as a **scheduled weekly workflow** (`.github/workflows/mutation-testing.yml`) every Monday at 03:00 UTC. It can also be triggered manually via `workflow_dispatch`. The HTML report is uploaded as a build artifact.
36+
37+
## Baseline Score
38+
39+
The initial baseline mutation score is **37.83%**, established with Stryker.NET 4.14.0.
40+
41+
| Metric | Count |
42+
|--------|-------|
43+
| Killed | 787 |
44+
| Survived | 707 |
45+
| Timeout | 6 |
46+
| No Coverage | 596 |
47+
| Compile Error | 145 |
48+
| Ignored | 677 |
49+
50+
The relatively low score is expected for an initial baseline. Many surviving mutants are in code paths not yet covered by tests (No Coverage) or in areas like console rendering and pipeline orchestration that are harder to unit test. The score will improve as tests are strengthened over time.

stryker-config.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"stryker-config": {
3+
"project": "TeaPie.csproj",
4+
"test-projects": ["./tests/TeaPie.Tests/TeaPie.Tests.csproj"],
5+
"solution": "./TeaPie.sln",
6+
"reporters": ["html", "progress", "cleartext"],
7+
"thresholds": {
8+
"high": 80,
9+
"low": 60,
10+
"break": 0
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)