### Initialize DiscoveredPoint Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/07-types-summary.md Example instantiation of a DiscoveredPoint object. ```kotlin DiscoveredPoint( pointId = "sample.Calculator_0", variantCount = 2, sourceLocation = "Calculator.kt:5", originalOperator = ">", variantOperators = [">=", "<"], occurrenceOnLine = 1 ) ``` -------------------------------- ### Configure Mutation Targets Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Example configuration for various target patterns. ```kotlin mutflow { targets = listOf( // Exact classes "com.example.payment.PaymentProcessor", // All in a domain package "com.example.domain.*", // All services everywhere "**.service.**", // Specific pattern "com.example.**.handler.*Handler" ) } ``` -------------------------------- ### Start with Explicit Targets Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/04-annotations.md Begin adoption by annotating only critical classes. ```kotlin @MutationTarget class PaymentProcessor { ... } ``` -------------------------------- ### Demonstrate Matching Logic Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Example showing how classes are matched via annotations and target patterns. ```kotlin // Given these configs: @MutationTarget class Calculator { ... } targets = listOf("com.example.service.*") // Result: // ✓ Calculator (from @MutationTarget) // ✓ com.example.service.PaymentService (matches pattern) // ✓ com.example.service.AuthService (matches pattern) // ✗ com.example.domain.Domain (no match) ``` -------------------------------- ### Start Run Callback Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md Logs run information before each class invocation. ```kotlin MutFlow.startRun(sessionId, run, mutation) ``` -------------------------------- ### Demonstrate class targeting logic Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Example showing how classes are selected for mutation based on annotations or pattern matching. ```kotlin // Targets config targets = listOf("com.example.service.*") // Classes (all targeted): @MutationTarget class Calculator { } // ✓ has annotation class com.example.service.PaymentService { } // ✓ matches pattern class com.example.service.AuthService { } // ✓ matches pattern // Classes (not targeted): class com.example.domain.User { } // ✗ no annotation, doesn't match ``` -------------------------------- ### Example Test Runner Output Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md Sample output format showing baseline and mutation test results. ```text CalculatorTest > Run without mutations > testIsPositive() PASSED CalculatorTest > Mutation: (Calculator.kt:8) > → >= > testIsPositive() PASSED CalculatorTest > Mutation: (Calculator.kt:8) > → >= > testIsPositiveZero() PASSED CalculatorTest > Mutation: (Calculator.kt:8) > → < > testIsPositive() PASSED ``` -------------------------------- ### Verification Mode Precedence Example Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Illustrates how environment variables override annotation settings. ```text Annotation: LENIENT Env var: STRICT Result: STRICT (env var wins) ``` -------------------------------- ### Access MutationTestingSummary Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/07-types-summary.md Example of retrieving and iterating over mutation testing summary results. ```kotlin val summary = session.getSummary() println("Killed: ${summary.killed}/${summary.totalMutations}") for ((mutation, result) in summary.results) { when (result) { is MutationResult.Killed -> println("✓ Killed") is MutationResult.Survived -> println("✗ Survived") is MutationResult.TimedOut -> println("⏱ Timeout") } } ``` -------------------------------- ### startSession(activeMutation: ActiveMutation?) Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/03-core-registry.md Starts a new mutation testing session. Fails if a session is already active. ```APIDOC ## startSession(activeMutation: ActiveMutation?) ### Description Starts a new mutation testing session. Fails if a session is already active. ### Parameters - **activeMutation** (ActiveMutation?) - Optional - Which mutation to activate (null for baseline/discovery) ### Throws - IllegalStateException if session already active ``` -------------------------------- ### Complex Mutation Testing Configuration Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md Example demonstrating the use of multiple configuration parameters simultaneously. ```kotlin @MutFlowTest( maxRuns = 20, // Cap at 20 runs for speed traps = [ "(Calculator.kt:8) > → >=", "(Calculator.kt:12) + → -" ], includeTargets = [Calculator::class, Validator::class], timeoutMs = 45_000, verificationMode = VerificationMode.LENIENT ) class CalculatorComplexTest { @Test fun multipleOperations() { val result = MutFlow.underTest { val a = calculator.add(10, 5) val b = calculator.multiply(a, 2) val valid = validator.isValid(b) Pair(b, valid) } assertEquals(Pair(30, true), result) } } ``` -------------------------------- ### Configure MutFlow in Gradle Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Basic setup for the MutFlow plugin within the build.gradle.kts file. ```kotlin plugins { kotlin("jvm") version "2.4.0" id("io.github.anschnapp.mutflow") version "1.0.2" } mutflow { enabled = true targets = listOf(...) } ``` -------------------------------- ### Compiler Plugin Option Output Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Example of the generated compiler plugin options based on target patterns. ```text --plugin-option=io.github.anschnapp.mutflow:target=com.example.Calculator --plugin-option=io.github.anschnapp.mutflow:target=com.example.service.* ``` -------------------------------- ### Enabled Setting Precedence Example Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Illustrates how command line arguments override build script and properties file settings. ```text Build script: true gradle.properties: false Command line: -Pmutflow.enabled=false Result: false (command line wins) ``` -------------------------------- ### Get registry state Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Returns a snapshot of the legacy global registry state. ```kotlin fun getRegistryState(): RegistryState ``` -------------------------------- ### Start a Mutation Testing Run Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Initializes a specific run within a session, supporting both baseline and mutation-specific execution. ```kotlin fun startRun(sessionId: SessionId, run: Int, mutation: Mutation? = null) ``` ```kotlin MutFlow.startRun(sessionId, 0, null) // Start baseline // ... run tests ... MutFlow.endRun(sessionId) MutFlow.startRun(sessionId, 1, Mutation("sample.Calculator_0", 0)) // ... run tests with mutation active ... MutFlow.endRun(sessionId) ``` -------------------------------- ### Configure Minimal MutFlow Setup Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Applies the MutFlow plugin and enables default settings including all targets, strict mode, and a 60s timeout. ```kotlin // build.gradle.kts plugins { id("io.github.anschnapp.mutflow") version "1.0.2" } // Test @MutFlowTest class MyTest { ... } ``` -------------------------------- ### Create a Mutation Testing Session Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Defines the signature for creating a new session and provides a usage example for configuring selection strategies and timeouts. ```kotlin fun createSession( selection: Selection, shuffle: Shuffle, maxRuns: Int, expectedTestCount: Int = 0, traps: List = emptyList(), includeTargets: List = emptyList(), excludeTargets: List = emptyList(), timeoutMs: Long = 60_000, verificationMode: VerificationMode = VerificationMode.STRICT ): SessionId ``` ```kotlin val sessionId = MutFlow.createSession( selection = Selection.MostLikelyStable, shuffle = Shuffle.PerChange, maxRuns = Int.MAX_VALUE, expectedTestCount = 5, timeoutMs = 60_000, verificationMode = VerificationMode.STRICT ) ``` -------------------------------- ### Start a mutation session in Kotlin Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/03-core-registry.md Initializes a new session, optionally specifying an active mutation. Throws an IllegalStateException if a session is already active. ```kotlin MutationRegistry.startSession(null) // Baseline // Code executes, discovers points MutationRegistry.startSession(ActiveMutation("Calculator_0", 0)) // Mutation 1 // Code executes with mutation active ``` -------------------------------- ### Handle MutationResult Types Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/07-types-summary.md Example of pattern matching on MutationResult types. ```kotlin val summary = session.getSummary() for ((mutation, result) in summary.results) { when (result) { is MutationResult.Killed -> { println("Killed by: ${result.testNames.joinToString(", ")}") } is MutationResult.Survived -> { println("SURVIVED - test gap!") } is MutationResult.TimedOut -> { println("Caused timeout - add // mutflow:ignore") } } } ``` -------------------------------- ### Infinite loop mutation example Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md A target class containing a loop that can be mutated into an infinite loop. ```kotlin @MutationTarget class InfiniteLoopTarget { fun countToN(n: Int) { var i = 0 while (i < n) { // Mutates to i > n → infinite loop i++ } } } ``` -------------------------------- ### Apply SuppressMutations to a Class Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/04-annotations.md Example of suppressing all mutations within a class. ```kotlin @MutationTarget @SuppressMutations class LegacyUtilities { fun log(msg: String) { ... } fun debug(msg: String) { ... } fun warn(msg: String) { ... } } ``` -------------------------------- ### Configure @MutFlowTest Annotation Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Example of applying the @MutFlowTest annotation to a test class with various parameters. ```kotlin @MutFlowTest( maxRuns = 20, traps = ["(Calculator.kt:5) > → >="], includeTargets = [Calculator::class], excludeTargets = [Logger::class], timeoutMs = 45_000, verificationMode = VerificationMode.LENIENT ) class CalculatorTest { ... } ``` -------------------------------- ### withSession(activeMutation, timeoutMs, onSessionEnd, block) Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/03-core-registry.md Executes a block within a synchronized mutation session. Acquires lock, starts session, executes block, ends session, releases lock. ```APIDOC ## withSession(activeMutation, timeoutMs, onSessionEnd, block) ### Description Executes a block within a synchronized mutation session. Acquires lock, starts session, executes block, ends session, releases lock. ### Parameters - **activeMutation** (ActiveMutation?) - Optional - Mutation to activate (null = baseline) - **timeoutMs** (Long) - Optional - Timeout per run in milliseconds - **onSessionEnd** ((SessionResult) -> Unit) - Optional - Callback invoked on both normal and exceptional paths - **block** (() -> T) - Required - Code to execute within session ### Returns - **Pair** - Block result + session results ``` -------------------------------- ### Get mutation display name Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Generates a human-readable string representation of a mutation in the format (FileName.kt:line) original → variant. ```kotlin fun getDisplayName(mutation: Mutation): String ``` -------------------------------- ### Build and Test Commands Source: https://github.com/anschnapp/mutflow/blob/master/CONTRIBUTING.md Use these Gradle commands to build the project modules and execute the test suite. ```bash ./gradlew build # Build all modules ./gradlew test # Run all tests ``` -------------------------------- ### Apply SuppressMutations to a Function Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/04-annotations.md Example of suppressing mutations for a specific function while leaving others active. ```kotlin @MutationTarget class PaymentService { @SuppressMutations fun logTransaction(id: String, amount: BigDecimal) { auditLog.record("txn=$id, amount=$amount") } fun processPayment(payment: Payment): Result = { ... } // Mutated } ``` -------------------------------- ### MutFlow.startRun Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Initializes a specific test run within a session. ```APIDOC ## MutFlow.startRun ### Description Starts a run within a session. Called by JUnit extension before each class template invocation. ### Parameters - **sessionId** (SessionId) - Required - The session ID - **run** (Int) - Required - Run number (0=baseline, 1+=mutations) - **mutation** (Mutation?) - Optional - Pre-selected mutation for this run (null for baseline) ``` -------------------------------- ### Print mutation testing summary Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Outputs a formatted summary of the mutation testing results to standard output. ```kotlin fun printSummary() ``` -------------------------------- ### Configure Lenient Adoption Mode Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Limits runs to 30 and sets verification to lenient, allowing the build to pass even if survivors are reported. ```kotlin // build.gradle.kts mutflow { targets = listOf("com.example.*") } // Test @MutFlowTest( maxRuns = 30, verificationMode = VerificationMode.LENIENT ) class LegacyServiceTest { ... } ``` -------------------------------- ### MutflowExtension Configuration Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md The MutflowExtension provides the DSL for configuring mutation testing behavior within the build.gradle.kts file. ```APIDOC ## MutflowExtension DSL ### Description Configure mutation testing behavior using the `mutflow` block in your `build.gradle.kts` file. ### Properties - **enabled** (Property) - Optional - Enable or disable mutation testing. Default: true. - **targets** (ListProperty) - Optional - List of target patterns for mutation injection. Empty by default, targeting only @MutationTarget annotated classes. ### Configuration Example ```kotlin mutflow { enabled = true targets = listOf( "com.example.Calculator", "com.example.service.*", "com.example.service.**", "com.example.*Service" ) } ``` ``` -------------------------------- ### Configure Repository Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Ensure Maven Central is included in your repositories to resolve MutFlow dependencies. ```kotlin repositories { mavenCentral() // Required } ``` -------------------------------- ### Verify Production JAR Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/00-index.md Run this script to ensure no mutations are present in the production build. ```bash scripts/mutflow-verify-jar.sh build/libs/my-app.jar ``` -------------------------------- ### Configure MutFlow in CI Pipeline Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Demonstrates running different verification modes across various test phases in a GitHub Actions workflow. ```bash #!/bin/bash # .github/workflows/test.yml # Phase 1: Fast feedback MUTFLOW_VERIFICATION_MODE=DISABLED \ ./gradlew test --tests "*.FastTest" # Phase 2: Full mutation testing MUTFLOW_VERIFICATION_MODE=STRICT \ ./gradlew test # Phase 3: Integration tests (lenient) MUTFLOW_VERIFICATION_MODE=LENIENT \ ./gradlew integrationTest ``` -------------------------------- ### MutFlow Execution Timeline Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md A trace of the internal JUnit extension lifecycle and mutation execution flow. ```text Extension: supportsClassTemplate() → true (has @MutFlowTest) Extension: provideClassTemplateInvocationContexts() → Create session → Count test methods: 2 → Create baseline context (run=0) ------- RUN 0 (BASELINE) ------- Before: MutFlow.startRun(sessionId, 0, null) Test: testAdd() → discovers mutation in calc.add() After: session.trackTestExecution(testAdd.uniqueId) Test: testIsPositive() → discovers mutation in calc.isPositive() After: session.trackTestExecution(testIsPositive.uniqueId) After invocation: session.endRun() Next: selectMutationForRun(1) → returns Mutation("Calculator_0", 0) ------- RUN 1 (MUTATION 1) ------- Before: MutFlow.startRun(sessionId, 1, Mutation("Calculator_0", 0)) → activates mutation in MutationRegistry Test: testAdd() → uses mutated code, test fails After: session.markTestFailed("testAdd") Test: testIsPositive() → may pass or fail After: session.markTestFailed("testIsPositive") if it fails After invocation: session.recordMutationResult() → result = Killed(testNames=["testAdd", "testIsPositive"]) session.endRun() Next: selectMutationForRun(2) → returns Mutation("Calculator_0", 1) ------- RUN 2 (MUTATION 2) ------- Before: MutFlow.startRun(sessionId, 2, Mutation("Calculator_0", 1)) Test: testAdd() → uses different mutated code ... After invocation: session.recordMutationResult() Next: selectMutationForRun(3) → returns Mutation("Calculator_1", 0) ------- RUN 3 (MUTATION 3) ------- ... (Mutation("Calculator_1", 0)) ------- RUN 4 (MUTATION 4) ------- ... (Mutation("Calculator_1", 1)) ------- RUN 5+ ------- selectMutationForRun(5) → null (maxRuns=5 reached) Stream terminates Extension: onClose() → MutFlow.closeSession(sessionId) → session.printSummary() Prints: ║ Total mutations discovered: 4 ║ ║ Tested this run: 4 ║ ║ ├─ Killed: 4 ✓ ║ ║ ├─ Survived: 0 ✓ ║ ``` -------------------------------- ### Use ActiveMutation in a Session Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/07-types-summary.md Demonstrates initializing an ActiveMutation and passing it to the MutationRegistry session. ```kotlin val active = ActiveMutation("sample.Calculator_0", 0) MutationRegistry.withSession(activeMutation = active) { ... } ``` -------------------------------- ### Configure Mutation Targets in Gradle Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/04-annotations.md Use the Gradle configuration to batch-target multiple classes by package pattern. ```kotlin mutflow { targets = listOf( "com.example.domain.*", "com.example.service.*" ) } ``` -------------------------------- ### Access RegistryState metrics Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/07-types-summary.md Retrieves the current registry state and prints summary statistics. ```kotlin val state = MutFlow.getRegistryState() println("Discovered ${state.discoveredPoints.size} points") println("Tested ${state.testedMutations.size} mutations") ``` -------------------------------- ### Configure MUTFLOW_VERIFICATION_MODE in CI/CD Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Demonstrates setting different verification modes across multiple test phases in a CI/CD pipeline. ```bash #!/bin/bash # Phase 1: Unit tests (fast) MUTFLOW_VERIFICATION_MODE=DISABLED ./gradlew test # Phase 2: Mutation testing (thorough) MUTFLOW_VERIFICATION_MODE=STRICT ./gradlew test # Phase 3: Integration tests (with lenient mutations) MUTFLOW_VERIFICATION_MODE=LENIENT ./gradlew integrationTest ``` -------------------------------- ### Execute code under test with manual parameters Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Executes a block under mutation testing with explicit run, selection, and shuffle parameters, creating an ephemeral session. ```kotlin fun underTest( run: Int, selection: Selection, shuffle: Shuffle, block: () -> T ): T ``` ```kotlin // Manual mutation testing loop val calculator = Calculator() // Run baseline (discovery) MutFlow.underTest(0, Selection.PureRandom, Shuffle.PerRun) { calculator.isPositive(5) } // Run mutation 1 MutFlow.underTest(1, Selection.PureRandom, Shuffle.PerRun) { calculator.isPositive(5) } // Run mutation 2 MutFlow.underTest(2, Selection.PureRandom, Shuffle.PerRun) { calculator.isPositive(5) } ``` -------------------------------- ### getSummary() Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Retrieves a comprehensive summary of the mutation testing results. ```APIDOC ## fun getSummary(): MutationTestingSummary ### Description Returns a summary of the mutation testing results. ### Returns - **MutationTestingSummary** - Total, tested, killed, survived, timed out, untested counts and result details. ``` -------------------------------- ### Configuring Verification Modes Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md Control how mutation survivors affect the build process using the verificationMode parameter. ```kotlin // Strict (default) — survivors fail build @MutFlowTest(verificationMode = VerificationMode.STRICT) class CriticalPaymentTest { ... } // Lenient — survivors reported but don't fail @MutFlowTest(verificationMode = VerificationMode.LENIENT) class PartialCoverageTest { ... } // Disabled — only baseline runs @MutFlowTest(verificationMode = VerificationMode.DISABLED) class FastFeedbackTest { ... } ``` -------------------------------- ### printSummary() Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Prints a formatted summary of the mutation testing results to standard output. ```APIDOC ## fun printSummary() ### Description Prints a formatted summary of mutation testing results to stdout. ``` -------------------------------- ### Standardized Method Signature Format Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/README.md The required format for displaying method signatures, including all parameters, default values, and return types. ```kotlin fun methodName( param1: Type1, param2: Type2 = defaultValue ): ReturnType ``` -------------------------------- ### Set Enabled Property via Different Methods Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Methods to configure the enabled state via build script, properties file, or command line. ```kotlin mutflow { enabled = false } ``` ```properties mutflow.enabled=false ``` ```bash ./gradlew test -Pmutflow.enabled=false ``` -------------------------------- ### Graduate to Strict Verification Mode Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/04-annotations.md Switch to STRICT mode once mutation coverage reaches a satisfactory level. ```kotlin @MutFlowTest(verificationMode = VerificationMode.STRICT) ``` -------------------------------- ### Combine includeTargets and excludeTargets Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Demonstrates the interaction between include and exclude parameters, where exclusion takes precedence. ```kotlin @MutFlowTest( includeTargets = [Calculator::class, Validator::class], excludeTargets = [Validator::class] ) ``` ```kotlin @MutFlowTest(includeTargets = [Calculator::class]) ``` -------------------------------- ### Implement mayReturnZeroClassTemplateInvocationContexts Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md Ensures the baseline test run is always executed. ```kotlin override fun mayReturnZeroClassTemplateInvocationContexts(context: ExtensionContext): Boolean ``` -------------------------------- ### Limit Mutation Runs with maxRuns Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Demonstrates how to control the number of mutation runs to balance feedback speed and test coverage. ```kotlin @MutFlowTest(maxRuns = 1) // Baseline only @MutFlowTest(maxRuns = 20) // Baseline + 19 mutations @MutFlowTest(maxRuns = Int.MAX_VALUE) // All (default) ``` -------------------------------- ### Configure MutFlow in Gradle Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/00-index.md Define mutation testing targets and enable the plugin within the build configuration. ```kotlin mutflow { enabled = true targets = listOf("com.example.*") } ``` -------------------------------- ### Configure MUTFLOW_VERIFICATION_MODE in CI Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md Use environment variables to control mutation verification behavior during CI pipeline phases. ```bash # Phase 1: Fast feedback (baseline only) MUTFLOW_VERIFICATION_MODE=DISABLED ./gradlew test # Phase 2: Full mutation testing ./gradlew test # Phase 3: Lenient adoption (report but don't fail) MUTFLOW_VERIFICATION_MODE=LENIENT ./gradlew test ``` -------------------------------- ### Source Location Reference Format Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/README.md The standard format for referencing the exact location of a public API within the project structure. ```text Source: mutflow-runtime/src/main/kotlin/io/github/anschnapp/mutflow/MutFlow.kt:53-79 ``` -------------------------------- ### getState() Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Returns a snapshot of the session's current state, including discovered points, touch counts, and active mutations. ```APIDOC ## fun getState(): SessionState ### Description Returns a snapshot of the session's current state. ### Returns - **SessionState** - Contains discovered points, touch counts, tested mutations, current run, and active mutation. ``` -------------------------------- ### Run coverage and mutation testing separately Source: https://github.com/anschnapp/mutflow/blob/master/docs/agent-guide.md Execute coverage and mutation testing as distinct Gradle tasks to prevent reporting issues. ```bash ./gradlew test -Pmutflow.enabled=false # coverage run ./gradlew test # mutation testing run ``` -------------------------------- ### Bypass partial run detection via Gradle Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md Run the full test class from the command line to avoid partial test run detection. ```bash # Run from IDE with "Run Class" not "Run Method" ./gradlew test --tests com.example.CalculatorTest ``` -------------------------------- ### Configure mutatedMain source set Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Defines the mutatedMain source set to mirror the main source set's Java, Kotlin, and resource directories. ```kotlin sourceSets { mutatedMain { java.srcDirs(main.java.srcDirs) // Same Java sources kotlin.srcDirs(main.kotlin.srcDirs) // Same Kotlin sources resources.srcDirs(main.resources.srcDirs) // Same resources } } ``` -------------------------------- ### Set mutation verification modes Source: https://github.com/anschnapp/mutflow/blob/master/docs/agent-guide.md Control build failure behavior using VerificationMode. STRICT fails on survivors, LENIENT reports them, and DISABLED skips mutation runs. ```kotlin @MutFlowTest(verificationMode = VerificationMode.STRICT) // default: survivors fail @MutFlowTest(verificationMode = VerificationMode.LENIENT) // survivors reported only @MutFlowTest(verificationMode = VerificationMode.DISABLED) // skip mutation runs entirely ``` -------------------------------- ### getRegistryState() Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Returns the current state of the legacy global registry. ```APIDOC ## getRegistryState() ### Description Returns the current state of the legacy global registry. ### Returns - **RegistryState** - snapshot of discovered points, touch counts, and tested mutations ``` -------------------------------- ### Configure CI phases via environment variables Source: https://github.com/anschnapp/mutflow/blob/master/docs/agent-guide.md Use the MUTFLOW_VERIFICATION_MODE environment variable to override annotation settings for CI pipeline stages. ```bash # Phase 1: fast feedback, regular tests only MUTFLOW_VERIFICATION_MODE=DISABLED ./gradlew test # Phase 2: full mutation testing ./gradlew test # Gradual adoption: run mutations, report survivors, don't block MUTFLOW_VERIFICATION_MODE=LENIENT ./gradlew test ``` -------------------------------- ### Configure Subplugin Options Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Passes target patterns to the compiler plugin via SubpluginOption. ```kotlin override fun applyToCompilation( kotlinCompilation: KotlinCompilation<*> ): Provider> { return project.provider { val options = mutableListOf() extension?.targets?.get()?.forEach { target -> options.add(SubpluginOption("target", target)) } options } } ``` -------------------------------- ### Configure Mutation Targets Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Specify multiple packages to be targeted for mutation within the mutflow configuration block. ```kotlin mutflow { targets = listOf( "com.example.domain.*", "com.example.service.*", "com.example.handler.*" ) } ``` -------------------------------- ### Retrieve mutation testing summary Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Provides a summary object containing counts for total, tested, killed, survived, and untested mutations. ```kotlin fun getSummary(): MutationTestingSummary ``` -------------------------------- ### Visualize Documentation Cross-Reference Map Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/FILE_MANIFEST.md A visual representation of the documentation structure and navigation flow between different files. ```text README.md (start here) ↓ 00-index.md (quick lookup) ├→ 01-runtime-api.md (core runtime) │ ├→ 07-types-summary.md (types) │ └→ 03-core-registry.md (integration) ├→ 02-junit-integration.md (JUnit) │ ├→ 01-runtime-api.md │ └→ 06-configuration.md ├→ 04-annotations.md (source marks) ├→ 05-gradle-plugin.md (build) │ └→ 06-configuration.md ├→ 06-configuration.md (all options) │ ├→ 05-gradle-plugin.md │ ├→ 02-junit-integration.md │ └→ 07-types-summary.md └→ 07-types-summary.md (type ref) ├→ 01-runtime-api.md └→ 03-core-registry.md ``` -------------------------------- ### Implement provideClassTemplateInvocationContexts Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md Provides invocation contexts lazily to orchestrate the mutation testing lifecycle. ```kotlin override fun provideClassTemplateInvocationContexts( context: ExtensionContext ): Stream ``` -------------------------------- ### MutationTestingSummary Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/07-types-summary.md The MutationTestingSummary class provides a snapshot of mutation testing metrics, including total counts, killed/survived mutations, and detailed results per mutation. ```APIDOC ## MutationTestingSummary ### Description Represents the outcome of a mutation testing session, containing aggregate statistics and a map of individual mutation results. ### Properties - **totalMutations** (Int) - Total mutations discovered (filtered by include/exclude targets) - **testedThisRun** (Int) - Mutations actually tested - **killed** (Int) - Mutations caught by at least one test - **survived** (Int) - Mutations not caught (test gaps) - **timedOut** (Int) - Mutations that caused timeout - **untested** (Int) - Mutations not yet tested (total - tested) - **results** (Map) - Detailed result per mutation ### Usage Example ```kotlin val summary = session.getSummary() println("Killed: ${summary.killed}/${summary.totalMutations}") ``` ``` -------------------------------- ### underTest(run: Int, selection: Selection, shuffle: Shuffle, block: () -> T) Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Executes a block of code under mutation testing with explicit parameters for manual control. ```APIDOC ## underTest(run: Int, selection: Selection, shuffle: Shuffle, block: () -> T) ### Description Executes the block under mutation testing with explicit parameters. Creates an ephemeral session for the call. ### Parameters - **run** (Int) - Required - Run number: 0=baseline/discovery, 1+=mutation runs - **selection** (Selection) - Required - How to select which mutation to test - **shuffle** (Shuffle) - Required - When to reseed the selection - **block** (() -> T) - Required - The code under test ### Returns - **T** - The result of the block ### Throws - **MutationsExhaustedException** - if all mutations have been tested ``` -------------------------------- ### Override Mutflow via Command Line Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Use Gradle properties to override plugin settings during execution. ```bash # Disable mutations from command line ./gradlew test -Pmutflow.enabled=false # Enable specific targets ./gradlew test -Pmutflow.targets=com.example.Calculator ``` -------------------------------- ### Inherit dependencies for mutatedMain Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Shows how the plugin automatically extends dependencies from the main source set to mutatedMain. ```kotlin // These are configured by the plugin: mutatedMainImplementation.extendsFrom(implementation) mutatedMainCompileOnly.extendsFrom(compileOnly) mutatedMainRuntimeOnly.extendsFrom(runtimeOnly) ``` -------------------------------- ### Mark Target Class Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/00-index.md Annotate classes intended for mutation testing. ```kotlin @MutationTarget class MyService { ... } ``` -------------------------------- ### Enable Plugin Debug Logging Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Toggle the DEBUG constant in the plugin source to enable verbose logging during build tasks. ```kotlin // In plugin source companion object { const val DEBUG = false // Set to true to enable private fun debug(msg: String) { if (DEBUG) println("[MUTFLOW-GRADLE] $msg") } } ``` -------------------------------- ### Configure mutation targets in Gradle Source: https://github.com/anschnapp/mutflow/blob/master/docs/agent-guide.md Define mutation targets using class names, package paths, or glob patterns within the mutflow Gradle block. ```kotlin // Option 2: configure in build.gradle.kts, no annotation on production code mutflow { targets = listOf( "com.example.Calculator", // exact class "com.example.service.*", // all classes in a package "com.example.service.**", // package and all subpackages "com.example.*Service", // glob pattern ) } ``` -------------------------------- ### Select Mutation for a Run Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Retrieves the next mutation to apply for a specific run number. ```kotlin fun selectMutationForRun(sessionId: SessionId, run: Int): Mutation? ``` ```kotlin val mutation = MutFlow.selectMutationForRun(sessionId, 1) if (mutation != null) { // Start this mutation run MutFlow.startRun(sessionId, 1, mutation) } ``` -------------------------------- ### Configure test task classpath Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Prepends mutatedMain output classes to the test task classpath to ensure mutated classes are loaded during testing. ```kotlin testTask.classpath = project.files( mutatedMain.output.classesDirs // Mutated classes first ) + testTask.classpath // Then original + dependencies ``` -------------------------------- ### Configure Lenient Verification Mode Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/04-annotations.md Use LENIENT mode to prevent build failures while initially setting up mutation testing. ```kotlin @MutFlowTest(verificationMode = VerificationMode.LENIENT) class PaymentTest { ... } ``` -------------------------------- ### Implement isApplicable for Kotlin Compilation Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Restricts the compiler plugin application to the mutatedMain compilation target. ```kotlin override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean { val enabled = extension?.enabled?.get() ?: true val isApplicable = enabled && kotlinCompilation.name == "mutatedMain" return isApplicable } ``` -------------------------------- ### Handle Test Exceptions Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md Manages exception handling for baseline and mutation runs, including mutation killing logic. ```kotlin TestExecutionExceptionHandler { context, throwable -> when { run == 0 -> { session?.markBaselineFailure() throw throwable } throwable is MutationTimedOutException -> { session?.markTestTimedOut() throw throwable // User sees failure, must add ignore } else -> { session?.markTestFailed(context.displayName) // Don't rethrow — mutation killed } } } ``` -------------------------------- ### MutFlow.selectMutationForRun Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Selects the next mutation to be applied for a specific test run. ```APIDOC ## MutFlow.selectMutationForRun ### Description Selects the next mutation for a run. Called by JUnit extension when building invocation contexts after the previous run completes. ### Parameters - **sessionId** (SessionId) - Required - The session ID - **run** (Int) - Required - Run number (1+ for mutation runs) ### Returns - **Mutation?** - Selected mutation, or null if exhausted or partial run detected ``` -------------------------------- ### reset() Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Resets all stored state, intended for testing purposes only. ```APIDOC ## reset() ### Description Resets all stored state (both sessions and legacy). Intended for testing only. ``` -------------------------------- ### Check Test Classpath Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Use this test method to verify that the application classes are being loaded from the mutatedMain directory. ```kotlin @Test fun checkClasspath() { val url = Calculator::class.java.protectionDomain.codeSource.location println("Calculator loaded from: $url") // Should point to mutatedMain/classes } ``` -------------------------------- ### Set Verification Mode Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/00-index.md Configure the verification mode to LENIENT for incremental adoption. ```kotlin @MutFlowTest(verificationMode = VerificationMode.LENIENT) ``` -------------------------------- ### MutFlow Runtime API Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/GENERATED.txt The MutFlow object provides the primary entry point for managing mutation testing sessions, including session lifecycle control and mutation execution management. ```APIDOC ## MutFlow Runtime API ### Description The `MutFlow` object is the central entry point for managing mutation testing sessions. It allows users to create, query, and control the lifecycle of mutation testing runs. ### Methods - **MutFlow.createSession()**: Initializes a new mutation testing session. - **MutFlow.closeSession()**: Closes the active session and releases resources. - **MutFlow.selectMutationForRun()**: Selects a specific mutation to be applied in the current run. - **MutFlow.startRun()**: Marks the beginning of a mutation test execution. - **MutFlow.endRun()**: Marks the completion of a mutation test execution. - **MutFlow.underTest()**: Provides access to the object currently under mutation test. - **MutFlow.getSession()**: Retrieves the current active `MutFlowSession`. - **MutFlow.hasUntestedMutations()**: Checks if there are remaining mutations to be tested. - **MutFlow.getRegistryState()**: Returns the current state of the mutation registry. ``` -------------------------------- ### Basic Mutation Testing Usage Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md Standard implementation of mutation testing using the @MutFlowTest annotation on a test class. ```kotlin @MutFlowTest class CalculatorTest { private val calculator = Calculator() @Test fun isPositiveReturnsTrueForPositive() { val result = MutFlow.underTest { calculator.isPositive(5) } assertTrue(result) } @Test fun isPositiveReturnsFalseForNegative() { val result = MutFlow.underTest { calculator.isPositive(-5) } assertFalse(result) } } ``` -------------------------------- ### Configure Mutflow Extension Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Define mutation testing behavior and target patterns within the mutflow block. ```kotlin mutflow { enabled = true // Enable/disable mutation testing targets = listOf( // Target patterns for mutation "com.example.Calculator", // Exact class "com.example.service.*", // Package "com.example.service.**", // Package + subpackages "com.example.*Service" // Glob pattern ) } ``` -------------------------------- ### Compare Annotation and Comment Suppression Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/04-annotations.md Demonstrates the functional equivalence between the annotation and inline comment suppression. ```kotlin @SuppressMutations fun log(msg: String) { ... } // Equivalent to: fun log(msg: String) { // mutflow:ignore (applied to all lines) logger.info(msg) } ``` -------------------------------- ### Configure mutation scope with annotations Source: https://github.com/anschnapp/mutflow/blob/master/docs/agent-guide.md Use includeTargets to whitelist specific classes or excludeTargets to skip infrastructure classes during mutation testing. ```kotlin // whitelist: only these classes produce active mutations @MutFlowTest(includeTargets = [Calculator::class]) class CalculatorIntegrationTest { /* ... */ } // blacklist: skip infrastructure reached by underTest @MutFlowTest(excludeTargets = [AuditLogger::class, MetricsService::class]) class PaymentServiceTest { /* ... */ } ``` -------------------------------- ### Define mutation targets using glob patterns Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Specify class inclusion patterns for mutation testing within the mutflow DSL. ```kotlin mutflow { targets = listOf( // Exact "com.example.domain.User", "com.example.domain.Payment", // All in package "com.example.service.*", // Package + subpackages "com.example.handler.**", // Glob patterns "com.example.**Validator", "**.util.*Util" ) } ``` -------------------------------- ### Set enabled property via different interfaces Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Methods to toggle mutation testing using Gradle DSL, properties files, or command-line flags. ```kotlin // In build.gradle.kts mutflow { enabled = false } // In gradle.properties mutflow.enabled=false // Command line ./gradlew test -Pmutflow.enabled=false ``` -------------------------------- ### Retrieve a session by ID Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Returns the session object for a given ID, or null if no session is found. ```kotlin fun getSession(sessionId: SessionId): MutFlowSession? ``` -------------------------------- ### MutFlow.createSession Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Creates a new mutation testing session for a test class, typically invoked by a JUnit extension. ```APIDOC ## MutFlow.createSession ### Description Creates a new session for a test class. Called by JUnit extension at the start of a @MutFlowTest class. ### Parameters - **selection** (Selection) - Required - How to select mutations (PureRandom, MostLikelyRandom, MostLikelyStable) - **shuffle** (Shuffle) - Required - When to reseed selection (PerRun or PerChange) - **maxRuns** (Int) - Required - Maximum number of runs (baseline + mutations) - **expectedTestCount** (Int) - Optional - Number of test methods for partial run detection - **traps** (List) - Optional - Mutation display names to test first - **includeTargets** (List) - Optional - Class names to include (whitelist) - **excludeTargets** (List) - Optional - Class names to exclude (blacklist) - **timeoutMs** (Long) - Optional - Timeout per mutation run in milliseconds - **verificationMode** (VerificationMode) - Optional - How to handle surviving mutations ### Returns - **SessionId** - Unique identifier for this session ``` -------------------------------- ### Access SessionState information Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/07-types-summary.md Retrieves the session state and checks for an active mutation. ```kotlin val session = MutFlow.getSession(sessionId) val state = session?.getState() if (state?.activeMutation != null) { println("Testing: ${state.activeMutation.pointId}") } ``` -------------------------------- ### Configure MutFlow Plugin Version Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Apply the plugin in your build script, ensuring the version is compatible with your Kotlin compiler version. ```kotlin plugins { kotlin("jvm") version "2.4.0" id("io.github.anschnapp.mutflow") version "1.0.2" // Must match Kotlin 2.4 } ``` -------------------------------- ### Add MutFlow Plugin Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/00-index.md Include the MutFlow plugin in the build.gradle.kts file. ```kotlin id("io.github.anschnapp.mutflow") version "1.0.2" ``` -------------------------------- ### Configure Mutation Traps for Debugging Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Forces specific mutations to be tested first in a defined order, useful for verifying assertions. ```kotlin // Test @MutFlowTest( traps = [ "(PaymentProcessor.kt:42) > → >=", "(PaymentProcessor.kt:48) * → /" ] ) class PaymentProcessorTest { ... } ``` -------------------------------- ### Define and Use Mutation Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/07-types-summary.md Represents a specific mutation point and variant index for testing. ```kotlin data class Mutation( val pointId: String, val variantIndex: Int ) ``` ```kotlin val mutation = Mutation( pointId = "sample.Calculator_0", variantIndex = 0 ) MutFlow.startRun(sessionId, 1, mutation) ``` -------------------------------- ### Debugging with Traps Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md Use the traps parameter to prioritize specific mutation points for debugging. ```kotlin @MutFlowTest(traps = ["(Calculator.kt:8) > → >="]) class CalculatorTest { @Test fun isPositiveReturnsFalseForZero() { val result = MutFlow.underTest { calculator.isPositive(0) } assertFalse(result) } } ``` -------------------------------- ### Retrieve session state Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Returns a snapshot of the current session state including discovered points and active mutations. ```kotlin fun getState(): SessionState ``` -------------------------------- ### Write Mutation Test Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/00-index.md Use the @MutFlowTest annotation and MutFlow.underTest wrapper to execute tests against mutations. ```kotlin @MutFlowTest class MyServiceTest { @Test fun myTest() { val result = MutFlow.underTest { service.method() } assertEquals(expected, result) } } ``` -------------------------------- ### underTest(block: () -> T) Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/01-runtime-api.md Executes a block of code under mutation testing using the active session. ```APIDOC ## underTest(block: () -> T) ### Description Executes the block under mutation testing using the active session. This is the preferred API when using @MutFlowTest annotation. ### Parameters - **block** (() -> T) - Required - The code under test ### Returns - **T** - The result of the block ### Throws - **IllegalStateException** - if no session is active on this thread - **MutationsExhaustedException** - if all mutations have been tested ``` -------------------------------- ### Common MutFlow Type Imports Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/07-types-summary.md Use these imports to access core mutation testing functionality, session identifiers, and JUnit extensions. ```kotlin import io.github.anschnapp.mutflow.MutFlow import io.github.anschnapp.mutflow.SessionId import io.github.anschnapp.mutflow.Mutation import io.github.anschnapp.mutflow.Selection import io.github.anschnapp.mutflow.Shuffle import io.github.anschnapp.mutflow.VerificationMode import io.github.anschnapp.mutflow.MutationResult import io.github.anschnapp.mutflow.MutationTestingSummary import io.github.anschnapp.mutflow.MutationsExhaustedException import io.github.anschnapp.mutflow.MutantSurvivedException import io.github.anschnapp.mutflow.MutationTarget import io.github.anschnapp.mutflow.SuppressMutations import io.github.anschnapp.mutflow.junit.MutFlowTest import io.github.anschnapp.mutflow.junit.MutFlowExtension ``` -------------------------------- ### Implement MutFlow Test Class Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md Annotate test classes with @MutFlowTest and wrap target code with MutFlow.underTest to enable mutation testing. ```kotlin @MutFlowTest(maxRuns = 5) class CalculatorTest { private val calc = Calculator() @Test fun testAdd() { val result = MutFlow.underTest { calc.add(2, 3) } assertEquals(5, result) } @Test fun testIsPositive() { val result = MutFlow.underTest { calc.isPositive(5) } assertTrue(result) } } ``` -------------------------------- ### Handle After Class Template Invocation Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/02-junit-integration.md Records mutation results and enforces verification modes after class execution. ```kotlin if (run > 0) { session.recordMutationResult() if (session.didMutationSurvive()) { if (verificationMode == STRICT) { throw MutantSurvivedException(mutation, displayName) } else { println("[mutflow] Mutation survived (lenient): $displayName") } } } MutFlow.endRun(sessionId) ``` -------------------------------- ### Define Targets Property Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Property definition for specifying target patterns for mutation injection. ```kotlin val targets: ListProperty ``` -------------------------------- ### Configure MutFlow for Large Codebases Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Limits mutation testing to specific packages and caps the total number of runs to 50. ```kotlin // build.gradle.kts mutflow { targets = listOf("com.example.domain.*") } // Test @MutFlowTest(maxRuns = 50) class DomainTest { ... } ``` -------------------------------- ### Configure Scoped Integration Tests Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/06-configuration.md Targets specific packages for mutation while excluding certain classes from the analysis. ```kotlin // build.gradle.kts mutflow { targets = listOf( "com.example.domain.*", "com.example.service.*", "com.example.infra.*" // Infrastructure ) } // Test @MutFlowTest( excludeTargets = [DatabaseService::class, Logger::class] ) class PaymentIntegrationTest { ... } ``` -------------------------------- ### Usage Patterns for @MutFlowTest Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/04-annotations.md Common configurations for applying the @MutFlowTest annotation to test classes. ```kotlin @MutFlowTest // Basic @MutFlowTest(maxRuns = 20) // Limit runs @MutFlowTest(traps = ["(Calc.kt:5) > → >="]) // Debugging @MutFlowTest(includeTargets = [Calculator::class]) // Integration tests @MutFlowTest(verificationMode = VerificationMode.LENIENT) // Gradual adoption ``` -------------------------------- ### Debug Surviving Mutation Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/00-index.md Use traps to isolate specific mutations and add assertions to catch them. ```kotlin @MutFlowTest(traps = ["(Calculator.kt:5) > → >="]) ``` ```kotlin @Test fun testBoundary() { val result = MutFlow.underTest { calc.isPositive(0) } assertFalse(result) // Catches the >= mutation } ``` -------------------------------- ### Add Traps for Survivors Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/04-annotations.md Define specific mutation traps to address individual survivors during the adoption process. ```kotlin @MutFlowTest(traps = ["(PaymentProcessor.kt:42) > → >="]) ``` -------------------------------- ### Define Enabled Property Source: https://github.com/anschnapp/mutflow/blob/master/_autodocs/05-gradle-plugin.md Property definition for enabling or disabling mutation testing. ```kotlin val enabled: Property ```