Instructions for LLM agents. Keep edits minimal (headers + bullets). Use
/agents-mdskill when editing.
Test classes follow naming pattern <SourceFile>Tests. Default to iOS (fastest).
make test-ios # all iOS tests
make test-ios ONLY_TESTING=SentryHttpTransportTests # single class
make test-ios ONLY_TESTING=SentryHttpTransportTests,SentryHubTests # multiple
make test-ios ONLY_TESTING=SentryHttpTransportTests/testFlush_WhenNoInternet # single method
make test # all platforms
make test-ui-critical # important UI testsScope assessment:
- Specific feature → run related test classes
- Core SDK (
SentryHub,SentryClient,SentrySDK) →make test-ios - Multiple areas or unsure →
make test-iosormake test
Only needed for SentryNetworkTrackerIntegrationTestServerTests (3 tests). Most tests run without it.
make run-test-server
./scripts/sentry-xcodebuild.sh --platform iOS --command test --test-plan Sentry_TestServer
make stop-test-server # always stop after usePattern: test<Function>_when<Condition>_should<Expected>()
testAdd_whenSingleItem_shouldAppendToStorage()testCapture_whenEmptyBuffer_shouldDoNothing()
func testExample() {
// -- Arrange --
let input = "test"
// -- Act --
let result = transform(input)
// -- Assert --
XCTAssertEqual(result, "TEST")
}Never use bare XCTAssert() — it produces poor failure messages. Use the most specific assertion available:
| Instead of | Use |
|---|---|
XCTAssert(a == b) |
XCTAssertEqual(a, b) |
XCTAssert(a != b) |
XCTAssertNotEqual(a, b) |
XCTAssert(a === b) |
XCTAssertIdentical(a, b) |
XCTAssert(a !== b) |
XCTAssertNotIdentical(a, b) |
XCTAssert(x) (any Bool) |
XCTAssertTrue(x) |
XCTAssert(!x) |
XCTAssertFalse(x) |
XCTAssert(x == nil) |
XCTAssertNil(x) |
XCTAssert(x != nil) |
XCTAssertNotNil(x) |
Prefer self-contained, readable tests. Duplicate test code if it improves clarity. Use helpers only for complex setup, shared fixtures, or genuinely reusable assertion logic.
Use guard case with early return over if case:
guard case .string(let value) = result else {
return XCTFail("Expected .string case")
}
XCTAssertEqual(value, "test")Use XCTUnwrap when XCTAssertEqual requires non-optional (e.g., accuracy: parameter):
XCTAssertEqual(try XCTUnwrap(result as? Double), 3.14, accuracy: 0.00001)For arrays, use element(at:) (returns nil on out-of-bounds) instead of direct subscript:
let array = try XCTUnwrap(result as? [Double])
XCTAssertEqual(try XCTUnwrap(array.element(at: 0)), 1.1, accuracy: 0.00001)
XCTAssertEqual(array.count, 2)- Prefer
structoverclassunless reference semantics are needed (shared mutable state,AnyObjectprotocols, mock observation)
When an error path cannot be reliably tested (hardcoded valid params, resource exhaustion, DYLD_INTERPOSE limitations):
- Remove the broken test
- Document why in the test file
- Comment at the error handling site in source
- Note in PR description