From xcode-mcp
This skill should be used when the user asks to "run tests", "run unit tests", "run UI tests", "run a specific test", "check test coverage", "run the test suite", "why is this test failing", "set up a test plan", "XCTest", or any task involving running or analyzing tests in an Xcode project.
How this skill is triggered — by the user, by Claude, or both
Slash command
/xcode-mcp:xcode-testingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Use the Xcode MCP to run tests, inspect results, and manage test plans. The MCP routes requests to Xcode's test runner, which provides live feedback and integrates with Test Navigator.
Use the Xcode MCP to run tests, inspect results, and manage test plans. The MCP routes requests to Xcode's test runner, which provides live feedback and integrates with Test Navigator.
"Run all tests in the project"
"Run the full test suite"
"Build and test the MyApp scheme"
"Run all tests in the MyAppTests target"
"Run the MyAppUITests UI test target"
"Run all tests in the UserRepositoryTests test class"
"Run the LoginViewModelTests test class"
"Run the test UserRepositoryTests/testFetchUserReturnsCorrectData"
"Run only the testLoginWithValidCredentials test method in AuthTests"
"Run all tests whose names contain 'Network'"
"Run tests in the DataLayer group"
The MCP response includes Xcode's test output. Key patterns to look for:
Test Suite 'MyAppTests' started
Test Case '-[MyAppTests.UserRepositoryTests testFetchUser]' started
Test Case '-[MyAppTests.UserRepositoryTests testFetchUser]' passed (0.032 seconds)
Test Case '-[MyAppTests.UserRepositoryTests testFetchUserFailsOnNetworkError]' failed (0.015 seconds)
...
Executed 47 tests, with 2 failures (0 unexpected) in 1.203 (1.421) seconds
When tests fail, the output includes:
file.swift:42: error: XCTAssertEqual failed("expected") is not equal to ("actual")// XCTAssertEqual(result, expected) failed: ("42") is not equal to ("0")
// → The function returned 0 instead of 42. Check the implementation logic.
// Asynchronous wait failed - Exceeded timeout of 2 seconds
// → Either the async operation is too slow or the expectation was never fulfilled
// Fix: Increase timeout or mock the slow dependency
// Fatal error: Unexpectedly found nil while unwrapping an Optional value
// → XCTest crashes, reporting as a test failure
// Fix: Use guard let or XCTUnwrap() in the test
// Expression is 'async' but is not marked with 'await'
// Fix: Mark test method as async and add await
"Show test coverage for the MyApp target"
"Which files have less than 80% test coverage?"
"Show coverage report after running tests"
Request coverage after running tests. Xcode generates coverage data per-file and per-function.
Test plans (.xctestplan files) configure which tests run and with what settings.
"Create a test plan called SmokeSuite that runs only the critical tests"
"Add the UserRepositoryTests and AuthTests classes to the SmokeSuite test plan"
"Set the test plan to run tests in parallel on the MyApp scheme"
"Enable code coverage collection in the default test plan"
"Set environment variable API_BASE_URL=https://staging.api.com in the test plan"
Useful test plan configurations:
"Run tests on the iPhone 16 Pro simulator"
"Run tests on iOS 17.0 and iOS 18.0 simulators"
"Run tests on the connected device"
When asked to write tests or make code more testable:
@testable import to access internal types in test targetsasync and use await on the system under test@MainActor-isolated test or use await MainActor.run { ... }XCTUnwrap() instead of force unwrapping in tests — provides better failure messagesXCTExpectFailure() marks known failures to prevent CI flakiness while tracking issuesUse xcodebuild test via Bash when:
-resultBundlePath for artifact collectionxcodebuild test \
-scheme MyApp \
-destination 'platform=iOS Simulator,name=iPhone 16' \
-resultBundlePath TestResults.xcresult
Provides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.
npx claudepluginhub mattwag05/mw-plugins --plugin xcode-mcp