Skip to main content
Selective testing intelligently determines which tests are impacted by your code changes, allowing you to run a focused subset of tests instead of your entire test suite.

Overview

Selective testing can reduce test execution time by 60-90% by only running tests affected by your changes.
Tuist analyzes your dependency graph and git changes to identify:
  • Tests in modified targets
  • Tests that depend on changed source files
  • Tests affected by dependency changes

How It Works

  1. Track changes - Tuist compares your current code against a baseline (usually main branch)
  2. Build dependency graph - Maps which tests depend on which source files
  3. Calculate impact - Determines which tests could be affected by changes
  4. Run focused tests - Executes only the necessary test subset

Getting Started

Basic Usage

Selective testing is enabled by default when using tuist test:
# Run only tests affected by your changes
tuist test
Tuist automatically compares against your project’s default branch to determine which tests to run.

First-Time Setup

1

Authenticate with Tuist Cloud

Selective testing requires Tuist Cloud to track test results:
tuist auth
2

Link your project

tuist project create
3

Run your full test suite once

Establish a baseline by running all tests:
tuist test --no-selective-testing
4

Use selective testing

Now selective testing will work automatically:
tuist test

Configuration

Disable Selective Testing

Run all tests regardless of changes:
tuist test --no-selective-testing

Filter by Test Type

tuist test --skip-ui-tests

Specify Test Targets

Run specific tests even with selective testing:
# Run all tests in a target
tuist test --test-targets MyAppTests

# Run specific test class
tuist test --test-targets MyAppTests/UserServiceTests

# Run specific test method
tuist test --test-targets MyAppTests/UserServiceTests/testUserLogin

How Tests Are Selected

Scenarios

Change: Edit UserService.swiftSelected tests:
  • All tests in targets that depend on the module containing UserService.swift
  • Tests that directly import or use UserService
Change: Edit UserServiceTests.swiftSelected tests:
  • Only tests within UserServiceTests.swift
Change: Update Alamofire from 5.8.0 to 5.9.0Selected tests:
  • All tests in targets that depend on Alamofire
  • All tests in targets that transitively depend on Alamofire
Change: No modified filesSelected tests:
  • None (Tuist reports “No tests to run”)
  • You can still force run with --no-selective-testing

CI/CD Integration

Pull Request Testing

Selective testing shines in CI environments:
GitHub Actions
name: Test
on: [pull_request]
jobs:
  test:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0  # Important: fetch full history
      
      - name: Install Tuist
        run: curl -Ls https://install.tuist.io | bash
      
      - name: Run selective tests
        run: tuist test
        env:
          TUIST_TOKEN: ${{ secrets.TUIST_TOKEN }}
Make sure to fetch the full git history (fetch-depth: 0) so Tuist can compare changes against the base branch.

Main Branch Testing

Always run full test suite on main:
name: Test Main
on:
  push:
    branches: [main]
jobs:
  test:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Install Tuist
        run: curl -Ls https://install.tuist.io | bash
      
      - name: Run all tests
        run: tuist test --no-selective-testing
        env:
          TUIST_TOKEN: ${{ secrets.TUIST_TOKEN }}

Caching Integration

Selective testing works seamlessly with binary caching:
# Tests use cached binaries when possible
tuist test
Tuist will:
  1. Use cached binaries for unchanged dependencies
  2. Run only tests affected by your changes
  3. Upload test results to Tuist Cloud
Combining selective testing with binary caching can reduce test time by 80-95% in CI.

Understanding Test Results

Test Summary

After running tests, Tuist shows:
 Selected 15 tests (skipped 142)
 All tests passed in 23.4s

Test selection breakdown:
  - 8 tests in modified targets
  - 7 tests affected by dependency changes
  - 142 tests skipped (no changes detected)

Cloud Dashboard

View detailed test analytics in Tuist Cloud:
  • Test execution time trends
  • Selective testing impact
  • Flaky test detection
  • Test success rates

Best Practices

Modular Architecture

Break your app into focused modules. Smaller, well-defined dependencies lead to better test selection.

Stable Dependencies

Keep stable code in separate frameworks. Infrequently changing dependencies won’t trigger unnecessary tests.

Comprehensive Tests

Write tests that cover public interfaces. Tuist selects tests based on dependency relationships.

Fast Test Execution

Optimize individual test speed. Selective testing reduces quantity, but each test should still be fast.

Troubleshooting

Possible causes:
  • Changes in a low-level dependency affect many targets
  • Wide dependency graph (everything depends on core framework)
  • Project structure needs modularization
Solutions:
  • Break up large, widely-used frameworks
  • Use protocols to decouple dependencies
  • Consider vertical slicing of features
Possible causes:
  • No source changes detected
  • Changes are in non-code files (e.g., README)
  • Git comparison issues
Solutions:
  • Verify changes with git status
  • Use --no-selective-testing to force run
  • Check baseline branch configuration
Possible causes:
  • Not authenticated with Tuist Cloud
  • Network connectivity issues
  • Project not linked
Solutions:
  • Run tuist auth to authenticate
  • Check network connectivity
  • Verify project link with tuist project show

Performance Impact

Small Changes

90-95% reductionSingle file modifications

Medium Changes

60-80% reductionMultiple related changes

Large Changes

20-40% reductionCore dependency updates

Next Steps

Build Insights

Analyze test performance and coverage

Binary Caching

Speed up test builds with caching