Skip to content
mutastic

Swift edition

Troubleshooting

When a run stops, it says why in one sentence, where it looked, and the command to run next, on stderr, with exit code 2 (3 when the tests themselves fail). This page is the cases you’re most likely to meet first, and what to do about each.

mutastic runs on the directory it’s given, or the one it’s run in, and that directory, or one above it, needs a Package.swift, an .xcodeproj or an .xcworkspace. From inside a package, mutastic run Sources/Pricing runs the package, as swift build would build it:

Terminal window
mutastic run nowhere
Terminal window
mutastic: there's no project in nowhere for mutastic to test.
It looked in /home/you/project/nowhere and every directory above it, for a Package.swift, an .xcodeproj or an .xcworkspace.
Go to your project, or name its directory:
mutastic run <project directory>

Name the package’s directory, the one with its Package.swift, or cd into it.

A word that’s nearly a command gets the command it was close to:

Terminal window
mutastic verfiy m86f9a31d samples/pricing
Terminal window
mutastic: mutastic has no command verfiy. There's one called verify.
mutastic verify m86f9a31d samples/pricing

Before any mutant runs, every test runs with no mutant in. A test that fails there would seem to catch every mutant it reaches, so the run stops and names it. Here a test that expects free shipping below the threshold was added to the pricing sample:

@Test func shippingIsFreeAtFortyNine() {
#expect(Pricing().shipping(total: 49) == 0)
}
Terminal window
mutastic run samples/pricing
Terminal window
mutastic: PricingTests.shippingIsFreeAtFortyNine() fails without any mutant, so mutastic can't judge one.
It failed: Expectation failed: (Pricing().shipping(total: 49) → 5) == 0
To run without it until it's fixed, list it under exclude-tests: in mutastic.yaml with a reason, or for this run add --exclude-tests='PricingTests.shippingIsFreeAtFortyNine()'
Its output is in samples/pricing/.build/mutastic/tests.log. To run it alone:
swift test --package-path samples/pricing --filter 'PricingTests\.shippingIsFreeAtFortyNine\(\)'

The run exits with 3. Fix the test, or the code, until swift test passes; the tests’ own output is in .build/mutastic/tests.log. A test that can’t pass here, one that needs a server or a fixed port, can be left out of every run with exclude-tests: in mutastic.yaml, or of one run with --exclude-tests (see Running on your project).

Some changes don’t compile in every place they’re made: a + on two strings has no -, say. mutastic finds the mutant the compiler’s error is in, withdraws it, and builds again; the progress line says how many were withdrawn, and the summary’s Build line how many rounds it took. A withdrawn mutant isn’t counted, for or against your tests. See How the tests are run.

Most of a run’s time is the build, the coverage pass and the mutants’ tests. To spend less:

  • --since=main runs only the mutants on lines changed since main, and --at the ones on the lines you name.
  • --shard=1/4 runs one share of the mutants, for splitting a run across CI jobs, and --from-shards puts the shares back together.
  • --exclude-tests leaves out a slow test that can’t catch anything.

An Xcode project takes longer than a package: see Xcode projects.

A project with several schemes, an Xcode that’s older than the one that saved the project, or tests for a platform mutastic doesn’t run on each stop with their own code: Xcode projects has them.