Skip to content

Commit 629e7fc

Browse files
authored
Merge pull request #15 from drag0sd0g/copilot/add-pit-mutation-testing
Add PIT mutation testing with enforced thresholds
2 parents e7466aa + ade3eff commit 629e7fc

File tree

5 files changed

+73
-4
lines changed

5 files changed

+73
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.idea
33
build
44
data-server
5+
data-server-test
56
*.class
67
*.log
78
*.jar

README.ja.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Quarkus と Java 21 で構築された、モダンでコンテナ化されたフ
3232
- 📊 **オブザーバビリティ**: Prometheus メトリクスと構造化ログ
3333
- 🔒 **セキュリティ**: CodeQL スキャンと Dependabot による依存関係更新
3434
-**品質管理**: Checkstyle、PMD、SpotBugs による静的解析
35-
- 🧪 **テスト済み**: 80% コードカバレッジ + 包括的な統合テスト
35+
- 🧪 **テスト済み**: 70% コードカバレッジ + 包括的な統合テスト + PIT ミューテーションテスト
3636
- 📖 **API ドキュメント**: OpenAPI/Swagger UI 同梱
3737
- 🌐 **REST API**: シンプルで分かりやすいファイルストレージ API
3838

@@ -300,8 +300,12 @@ docker-compose logs -f
300300

301301
- **ユニットテスト**: JUnit 5 + Mockito
302302
- **統合テスト**: Testcontainers + Docker Compose
303-
- **コードカバレッジ**: Jacoco レポート、80% 閾値設定
303+
- **コードカバレッジ**: Jacoco レポート、70% 閾値設定
304304
- テストレポートは _build/jacocoHtml/index.html_ に出力
305+
- **ミューテーションテスト**: PIT (PITest) による強制的な閾値設定
306+
- クライアント: 40% ミューテーションスコア閾値
307+
- サーバー: 70% ミューテーションスコア閾値
308+
- レポートは _build/reports/pitest/index.html_ に出力
305309
- **継続的インテグレーション**: GitHub Actions による自動テスト
306310

307311
全てのテストを実行:
@@ -317,6 +321,16 @@ docker-compose logs -f
317321
# カバレッジレポートを表示: file-storage-server/build/jacocoHtml/index.html を開く
318322
```
319323

324+
ミューテーションテストを実行:
325+
326+
```bash
327+
./gradlew pitest
328+
# クライアントレポートを表示: file-storage-client/build/reports/pitest/index.html を開く
329+
# サーバーレポートを表示: file-storage-server/build/reports/pitest/index.html を開く
330+
```
331+
332+
**注意**: ミューテーションテストはビルドの一部として自動的に実行されます。ミューテーションスコアが設定された閾値を下回ると、ビルドは失敗します。
333+
320334
---
321335

322336
## 📚 API ドキュメント

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ A modern, containerized file storage service with REST API, built with Quarkus a
3232
- 📊 **Observability**: Prometheus metrics and structured logging
3333
- 🔒 **Security**: CodeQL scanning and dependency updates via Dependabot
3434
-**Quality**: Checkstyle, PMD, and SpotBugs static analysis
35-
- 🧪 **Tested**: 80% code coverage + comprehensive integration tests
35+
- 🧪 **Tested**: 70% code coverage + comprehensive integration tests + PIT mutation testing
3636
- 📖 **API Documentation**: OpenAPI/Swagger UI included
3737
- 🌐 **REST API**: Simple, well-documented file storage API
3838

@@ -306,8 +306,12 @@ docker-compose logs -f
306306

307307
- **Unit Tests**: JUnit 5 with Mockito
308308
- **Integration Tests**: Testcontainers + Docker Compose
309-
- **Code Coverage**: Jacoco reporting with 80% threshold
309+
- **Code Coverage**: Jacoco reporting with 70% threshold
310310
- Test reports visible in _build/jacocoHtml/index.html_
311+
- **Mutation Testing**: PIT (PITest) with enforced thresholds
312+
- Client: 40% mutation score threshold
313+
- Server: 70% mutation score threshold
314+
- Reports visible in _build/reports/pitest/index.html_
311315
- **Continuous Integration**: GitHub Actions with automated testing
312316

313317
Run all tests:
@@ -323,6 +327,16 @@ Run with coverage:
323327
# View coverage report: open file-storage-server/build/jacocoHtml/index.html
324328
```
325329

330+
Run mutation testing:
331+
332+
```bash
333+
./gradlew pitest
334+
# View client report: open file-storage-client/build/reports/pitest/index.html
335+
# View server report: open file-storage-server/build/reports/pitest/index.html
336+
```
337+
338+
**Note**: Mutation testing is automatically run as part of the build. The build will fail if mutation scores drop below the configured thresholds.
339+
326340
---
327341

328342
## 📚 API Documentation

file-storage-client/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id 'java'
3+
id 'info.solidsoft.pitest' version '1.15.0'
34
}
45

56
apply plugin: 'jacoco'
@@ -63,4 +64,20 @@ jacocoTestCoverageVerification {
6364
}
6465
}
6566
}
67+
}
68+
69+
pitest {
70+
junit5PluginVersion = '1.2.1'
71+
targetClasses = ['com.tools.fsclient.*']
72+
targetTests = ['com.tools.fsclient.*']
73+
mutators = ['DEFAULTS']
74+
threads = 4
75+
outputFormats = ['HTML', 'XML']
76+
timestampedReports = false
77+
mutationThreshold = 40
78+
coverageThreshold = 70
79+
}
80+
81+
tasks.named('check') {
82+
dependsOn tasks.named('pitest')
6683
}

file-storage-server/build.gradle

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'java'
33
id 'io.quarkus'
4+
id 'info.solidsoft.pitest' version '1.15.0'
45
}
56

67
apply plugin: 'jacoco'
@@ -61,4 +62,26 @@ jacocoTestCoverageVerification {
6162
}
6263
}
6364
}
65+
}
66+
67+
pitest {
68+
junit5PluginVersion = '1.2.1'
69+
targetClasses = ['com.tools.fsserver.*']
70+
targetTests = ['com.tools.fsserver.*']
71+
mutators = ['DEFAULTS']
72+
threads = 4
73+
outputFormats = ['HTML', 'XML']
74+
timestampedReports = false
75+
mutationThreshold = 70
76+
coverageThreshold = 70
77+
}
78+
79+
// PITest needs to run after Quarkus generates its sources, otherwise it may try to
80+
// analyze classes before they are fully available, leading to incorrect results
81+
tasks.named('pitest') {
82+
mustRunAfter tasks.named('compileQuarkusGeneratedSourcesJava')
83+
}
84+
85+
tasks.named('check') {
86+
dependsOn tasks.named('pitest')
6487
}

0 commit comments

Comments
 (0)