Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,24 @@
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=deploy-on-friday-swift-mutation-testing&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=deploy-on-friday-swift-mutation-testing)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=deploy-on-friday-swift-mutation-testing&metric=coverage)](https://sonarcloud.io/summary/new_code?id=deploy-on-friday-swift-mutation-testing)

**Find untested behaviour in Swift codebases.**
**Measure and improve test effectiveness in Swift codebases using mutation testing.**

`swift-mutation-testing` is a CLI for mutation testing of Xcode + XCTest projects. It modifies your source code in small, targeted ways — mutations — and runs your test suite against each one. A mutation that goes undetected means a test is missing or an assertion is too weak. The result is a mutation score that measures how effectively your tests catch real bugs.
`swift-mutation-testing` is a CLI for mutation testing of Xcode + XCTest projects. It modifies your source code in small, targeted ways — mutations — and runs your test suite against each one. A mutation that goes undetected reveals missing tests or weak assertions. The result is a mutation score that reflects how effectively your tests catch real bugs.

## Why

Traditional test coverage does not guarantee that tests catch real bugs.

Mutation testing introduces controlled changes to your code to verify that your tests fail when behavior changes. Surviving mutations indicate gaps in test effectiveness.

## Features

- Mutation testing for Xcode + XCTest projects
- Measures test effectiveness through mutation score
- Supports multiple mutation operators
- Provides detailed reports per file and mutation
- Configurable via YAML
- Can be integrated into CI pipelines

## Install

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftMutationTesting/CLI/HelpText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum HelpText {
--scheme <scheme> Xcode scheme to build and test (required)
--destination <destination> xcodebuild destination specifier (required)
--target <test-target> Test target name
--timeout <seconds> Per-mutant test timeout in seconds (default: 60)
--timeout <seconds> Per-mutant test timeout in seconds (default: 120)
--concurrency <n> Number of parallel test workers (default: CPUs - 1)
--no-cache Disable the result cache
--output <json-path> Write mutation report JSON to path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ struct ConfigurationFileWriter: Sendable {
}

lines.append("")
lines.append("# Per-mutant test timeout in seconds (default: 60)")
lines.append("timeout: 60")
lines.append("# Per-mutant test timeout in seconds (default: 120)")
lines.append("timeout: 120")
lines.append("")
lines.append("# Number of parallel workers (default: max(1, CPU count - 1))")
lines.append("# concurrency: 4")
lines.append("concurrency: 4")
lines.append("")
lines.append("# Disable result cache (re-runs all mutants on every execution)")
lines.append("# noCache: true")
lines.append("")
lines.append("# Report output paths")
lines.append("# output: mutation-report.json")
lines.append("# htmlOutput: mutation-report.html")
lines.append("# sonarOutput: sonar-report.json")
lines.append("sonarOutput: sonar-mutation-report.json")
lines.append("")
lines.append("# Source file glob patterns to exclude from mutation")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

struct RunnerConfiguration: Sendable {
static let defaultTimeout: Double = 60.0
static let defaultTimeout: Double = 120.0
static let defaultConcurrency: Int = max(1, ProcessInfo.processInfo.processorCount - 1)

let projectPath: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ struct ConfigurationFileWriterTests {
try writer.write(to: dir.path, project: .empty)

let values = try ConfigurationFileParser().parse(at: dir.path)
#expect(values["timeout"] == "60")
#expect(values["concurrency"] == nil)
#expect(values["timeout"] == "120")
#expect(values["concurrency"] == "4")
}

@Test("Given multiple schemes detected, when write called, then available schemes comment is included")
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Project identification
sonar.projectKey=deploy-on-friday-swift-mutation-testing
sonar.projectName=Swift Mutation Testing
sonar.projectDescription=Find untested behaviour in Swift codebases.
sonar.projectDescription=Measure and improve test effectiveness in Swift codebases using mutation testing.
sonar.organization=deploy-on-friday

# Source code
Expand Down