/ios:mobiai-ios-testingfrom ios
Guides writing and running iOS tests including XCTest unit tests, XCUITest UI tests, and snapshot tests with the Point-Free SnapshotTesting library. Covers test structure, async testing, mocking, and naming conventions.
Ships in ios. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Community contribution welcome! Help improve this skill with your XCTest patterns, mocking strategies, and testing tips.
Guide to writing and running tests in iOS projects.
| Type | Target | Framework | Speed |
|---|---|---|---|
| Unit | MyAppTests | XCTest | Fast |
| UI | MyAppUITests | XCUITest | Slow |
| Snapshot | MyAppTests | SnapshotTesting (pointfree) | Medium |
MyApp/Feature/MyViewModel.swiftMyAppTests/Feature/MyViewModelTests.swiftimport XCTest
@testable import MyApp
final class MyViewModelTests: XCTestCase {
private var sut: MyViewModel!
private var mockRepository: MockRepository!
override func setUp() {
super.setUp()
mockRepository = MockRepository()
sut = MyViewModel(repository: mockRepository)
}
override func tearDown() {
sut = nil
mockRepository = nil
super.tearDown()
}
func testLoadData_setsStateToSuccess_whenRepositoryReturnsData() async {
// Given
mockRepository.stubbedResult = [Item(id: "1", name: "Test")]
// When
await sut.loadData()
// Then
XCTAssertEqual(sut.state, .success([Item(id: "1", name: "Test")]))
}
func testLoadData_setsStateToError_whenRepositoryThrows() async {
// Given
mockRepository.stubbedError = NSError(domain: "", code: -1)
// When
await sut.loadData()
// Then
if case .error = sut.state {
// Expected
} else {
XCTFail("Expected error state")
}
}
}
// Pattern: testMethodName_expectedBehavior_whenCondition
func testCalculateTotal_returnsZero_whenCartIsEmpty() { ... }
func testFormatPrice_throws_whenAmountIsNegative() { ... }
// async/await
func testFetchData_returnsItems() async throws {
let items = try await sut.fetchData()
XCTAssertFalse(items.isEmpty)
}
// Combine
func testPublisher_emitsValue() {
let expectation = expectation(description: "Value emitted")
var received: String?
sut.publisher
.sink { value in
received = value
expectation.fulfill()
}
.store(in: &cancellables)
sut.trigger()
wait(for: [expectation], timeout: 1.0)
XCTAssertEqual(received, "expected")
}
class MockRepository: RepositoryProtocol {
var stubbedResult: [Item] = []
var stubbedError: Error?
var fetchDataCallCount = 0
func fetchData() async throws -> [Item] {
fetchDataCallCount += 1
if let error = stubbedError { throw error }
return stubbedResult
}
}
final class MyAppUITests: XCTestCase {
let app = XCUIApplication()
override func setUp() {
super.setUp()
continueAfterFailure = false
app.launch()
}
func testLogin_navigatesToHome() {
app.textFields["Email"].tap()
app.textFields["Email"].typeText("[email protected]")
app.secureTextFields["Password"].tap()
app.secureTextFields["Password"].typeText("password")
app.buttons["Login"].tap()
XCTAssertTrue(app.staticTexts["Welcome"].waitForExistence(timeout: 5))
}
}
# All unit tests
xcodebuild test -scheme MyApp -destination 'platform=iOS Simulator,name=iPhone 15 Pro' -quiet
# Specific test class
xcodebuild test -scheme MyApp -destination '...' -only-testing:MyAppTests/MyViewModelTests
# Specific test method
xcodebuild test -scheme MyApp -destination '...' -only-testing:MyAppTests/MyViewModelTests/testLoadData_setsStateToSuccess
# UI tests
xcodebuild test -scheme MyApp -destination '...' -only-testing:MyAppUITests
import Quick
import Nimble
@testable import MyApp
class MyViewModelSpec: QuickSpec {
override class func spec() {
describe("MyViewModel") {
var sut: MyViewModel!
beforeEach { sut = MyViewModel() }
context("when data loads successfully") {
it("sets state to success") {
expect(sut.state).toEventually(equal(.success))
}
}
}
}
}
Want to improve this skill? Add your testing patterns, mocking strategies, and CI tips via a PR.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
xctest, xcuitest, snapshot-testing, swift-testing, ios-testing
npx claudepluginhub arisguimera/mobiai-core --plugin ios4 skills in this plugin
/mobiai-ios-architectureUse when creating features, refactoring, or navigating an iOS codebase — understand project structure, find where to make changes, follow existing patterns./mobiai-ios-buildUse when building an iOS project, configuring schemes, troubleshooting build failures, or managing dependencies with CocoaPods or SPM./mobiai-ios-deviceUse when interacting with an iOS Simulator — run simctl commands, capture screenshots, read device logs, manage simulators.2 plugins ship this exact skill · first indexed Jul 20, 2026
Other plugins' skills for the same job