Test Insights
REQUIREMENTS
Test insights help you monitor your test suite's health by identifying slow tests or quickly understanding failed CI runs. As your test suite grows, it becomes increasingly difficult to spot trends like gradually slowing tests or intermittent failures. Tuist Test Insights provides you with the visibility you need to maintain a fast and reliable test suite.
With Test Insights, you can answer questions such as:
- Have my tests become slower? Which ones?
- Which tests are flaky and need attention?
- Why did my CI run fail?
Setup
To start tracking your tests, you can leverage the tuist inspect test command by adding it to your scheme's test post-action:

In case you're using Mise, your script will need to activate tuist in the post-action environment:
# -C ensures that Mise loads the configuration from the Mise configuration
# file in the project's root directory.
$HOME/.local/bin/mise x -C $SRCROOT -- tuist inspect testMISE & PROJECT PATHS
Your environment's PATH environment variable is not inherited by the scheme post action, and therefore you have to use Mise's absolute path, which will depend on how you installed Mise. Moreover, don't forget to inherit the build settings from a target in your project such that you can run Mise from the directory pointed to by $SRCROOT.
Your test runs are now tracked as long as you are logged in to your Tuist account. You can access your test insights in the Tuist dashboard and see how they evolve over time:

Apart from overall trends, you can also dive deep into each individual test, such as when debugging failures or slow tests on the CI:

Generated projects
INFO
Auto-generated schemes automatically include the tuist inspect test post-action.
If you are not interested in tracking test insights in your auto-generated schemes, disable them using the testInsightsDisabled generation option.
If you are using generated projects with custom schemes, you can set up post-actions for test insights:
let project = Project(
name: "MyProject",
targets: [
// Your targets
],
schemes: [
.scheme(
name: "MyApp",
shared: true,
buildAction: .buildAction(targets: ["MyApp"]),
testAction: .testAction(
targets: ["MyAppTests"],
postActions: [
// Test insights: Track test duration and flakiness
.executionAction(
title: "Inspect Test",
scriptText: """
$HOME/.local/bin/mise x -C $SRCROOT -- tuist inspect test
""",
target: "MyAppTests"
)
]
),
runAction: .runAction(configuration: "Debug")
)
]
)If you're not using Mise, your scripts can be simplified to:
testAction: .testAction(
targets: ["MyAppTests"],
postActions: [
.executionAction(
title: "Inspect Test",
scriptText: "tuist inspect test"
)
]
)Continuous integration
To track test insights on CI, you will need to ensure that your CI is authenticated.
Additionally, you will either need to:
- Use the
tuist xcodebuildcommand when invokingxcodebuildactions. - Add
-resultBundlePathto yourxcodebuildinvocation.
When xcodebuild tests your project without -resultBundlePath, the required result bundle files are not generated. The tuist inspect test post-action requires these files to analyze your tests.
