Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Commit d218fc8

Browse files
committed
test: Added mutation tests
1 parent 58dc690 commit d218fc8

7 files changed

Lines changed: 121 additions & 1 deletion

File tree

.config/dotnet-tools.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-stryker": {
6+
"version": "3.0.1",
7+
"commands": [
8+
"dotnet-stryker"
9+
]
10+
}
11+
}
12+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: 'Mutation tests'
2+
3+
4+
on:
5+
workflow_dispatch: # To can dispatch manually
6+
7+
push: # First pipeline to run when deploy a new version
8+
branches:
9+
- main
10+
paths:
11+
- "src/**" # Only run when exists changes in source code
12+
- "tests/**" # Only run when exists changes in tests code
13+
14+
pull_request:
15+
types: [opened, reopened, edited, synchronize]
16+
branches:
17+
- main
18+
19+
20+
env:
21+
SDK_VERSION: '7.0.100'
22+
23+
GIT_ORGANIZATION: 'TechNobre'
24+
PROJECT_NAME: 'PowerUtils.AspNetCore.ErrorHandler'
25+
TEST_PROJECT_PATH: 'tests/PowerUtils.AspNetCore.ErrorHandler.Tests/PowerUtils.AspNetCore.ErrorHandler.Tests.csproj'
26+
27+
28+
permissions:
29+
pull-requests: write # To can create a comment with the results
30+
31+
32+
jobs:
33+
34+
test-project:
35+
name: "Mutation tests"
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- name: "Checkout"
40+
uses: actions/checkout@v3
41+
42+
- name: "Setup .NET"
43+
uses: actions/setup-dotnet@v3
44+
with:
45+
dotnet-version: ${{ env.SDK_VERSION }}
46+
47+
- name: "Restore .NET Tools"
48+
run: dotnet tool restore
49+
50+
- name: "Restore dependencies"
51+
run: dotnet restore
52+
53+
- name: "Build"
54+
run: dotnet build --configuration Release --no-restore
55+
56+
- name: "Test for main version"
57+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
58+
run: dotnet stryker -tp ${{ env.TEST_PROJECT_PATH }} --reporter markdown --reporter progress --reporter dashboard --dashboard-api-key ${{ secrets.STRYKER_API_KEY }} --version main
59+
60+
- name: "Get branch name"
61+
if: github.event_name == 'pull_request'
62+
id: branch-name
63+
uses: tj-actions/branch-names@v6
64+
65+
- name: "Display branch details"
66+
if: github.event_name == 'pull_request'
67+
run: |
68+
echo "Branch name is ${{ steps.branch-name.outputs.current_branch }}"
69+
70+
- name: "Test for PR"
71+
if: github.event_name == 'pull_request'
72+
run: dotnet stryker -tp ${{ env.TEST_PROJECT_PATH }} --reporter markdown --reporter progress --reporter dashboard --dashboard-api-key ${{ secrets.STRYKER_API_KEY }} --version ${{ steps.branch-name.outputs.current_branch }}-${{ github.run_number }}
73+
74+
- name: "Comment PR"
75+
uses: actions/github-script@v6.3.3
76+
if: github.event_name == 'pull_request'
77+
with:
78+
github-token: ${{ secrets.GITHUB_TOKEN }}
79+
script: |
80+
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
81+
const message = `🚀 **Stryker report generated** 🚀
82+
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2F${{ env.GIT_ORGANIZATION }}%2F${{ env.PROJECT_NAME }}%2F${{ steps.branch-name.outputs.current_branch }}-${{ github.run_number }})](https://dashboard.stryker-mutator.io/reports/github.com/${{ env.GIT_ORGANIZATION }}/${{ env.PROJECT_NAME }}/${{ steps.branch-name.outputs.current_branch }}-${{ github.run_number }})
83+
To more details: https://dashboard.stryker-mutator.io/reports/github.com/${{ env.GIT_ORGANIZATION }}/${{ env.PROJECT_NAME }}/${{ steps.branch-name.outputs.current_branch }}-${{ github.run_number }}`;
84+
github.rest.issues.createComment({
85+
issue_number,
86+
owner,
87+
repo,
88+
body: message
89+
});
90+
91+
- name: "Publish report"
92+
run: |
93+
cat $(find ./StrykerOutput/* -name "*.md") > $GITHUB_STEP_SUMMARY

.github/workflows/sonarcloud.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
uses: actions/checkout@v3
4141
with:
4242
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
43-
43+
4444
- name: "Cache SonarCloud packages"
4545
uses: actions/cache@v3
4646
with:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,6 @@ $RECYCLE.BIN/
457457
## Sonar
458458
.sonarqube
459459
sonarscan.bat
460+
461+
## Stryker
462+
StrykerOutput

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
***Handler to standardize error responses***
66

77
![Tests](https://github.com/TechNobre/PowerUtils.AspNetCore.ErrorHandler/actions/workflows/tests.yml/badge.svg)
8+
[![Mutation tests](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FTechNobre%2FPowerUtils.AspNetCore.ErrorHandler%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/TechNobre/PowerUtils.AspNetCore.ErrorHandler/main)
9+
810
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=TechNobre_PowerUtils.AspNetCore.ErrorHandler&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=TechNobre_PowerUtils.AspNetCore.ErrorHandler)
911
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=TechNobre_PowerUtils.AspNetCore.ErrorHandler&metric=coverage)](https://sonarcloud.io/summary/new_code?id=TechNobre_PowerUtils.AspNetCore.ErrorHandler)
12+
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=TechNobre_PowerUtils.AspNetCore.ErrorHandler&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=TechNobre_PowerUtils.AspNetCore.ErrorHandler)
13+
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=TechNobre_PowerUtils.AspNetCore.ErrorHandler&metric=bugs)](https://sonarcloud.io/summary/new_code?id=TechNobre_PowerUtils.AspNetCore.ErrorHandler)
1014

1115
[![NuGet](https://img.shields.io/nuget/v/PowerUtils.AspNetCore.ErrorHandler.svg)](https://www.nuget.org/packages/PowerUtils.AspNetCore.ErrorHandler)
1216
[![Nuget](https://img.shields.io/nuget/dt/PowerUtils.AspNetCore.ErrorHandler.svg)](https://www.nuget.org/packages/PowerUtils.AspNetCore.ErrorHandler)

README.nuget.org.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
***Handler to standardize error responses***
22

33
![Tests](https://github.com/TechNobre/PowerUtils.AspNetCore.ErrorHandler/actions/workflows/tests.yml/badge.svg)
4+
[![Mutation tests](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FTechNobre%2FPowerUtils.AspNetCore.ErrorHandler%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/TechNobre/PowerUtils.AspNetCore.ErrorHandler/main)
5+
46
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=TechNobre_PowerUtils.AspNetCore.ErrorHandler&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=TechNobre_PowerUtils.AspNetCore.ErrorHandler)
57
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=TechNobre_PowerUtils.AspNetCore.ErrorHandler&metric=coverage)](https://sonarcloud.io/summary/new_code?id=TechNobre_PowerUtils.AspNetCore.ErrorHandler)
8+
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=TechNobre_PowerUtils.AspNetCore.ErrorHandler&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=TechNobre_PowerUtils.AspNetCore.ErrorHandler)
9+
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=TechNobre_PowerUtils.AspNetCore.ErrorHandler&metric=bugs)](https://sonarcloud.io/summary/new_code?id=TechNobre_PowerUtils.AspNetCore.ErrorHandler)
610

711

812

stryker.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dotnet tool restore
2+
dotnet restore
3+
dotnet build --no-restore
4+
dotnet stryker -tp tests/PowerUtils.AspNetCore.ErrorHandler.Tests/PowerUtils.AspNetCore.ErrorHandler.Tests.csproj -p src/PowerUtils.AspNetCore.ErrorHandler.csproj --reporter cleartext --reporter html -o

0 commit comments

Comments
 (0)