Testing — Foundations Skill
Purpose
Route Apple-platform testing implementation tasks to the minimum required
Knowledge Contracts. v1 scope is a curated subset of XCTest (case
structure, assertions, skipping), the newer Swift Testing framework
(@Test/#expect/#require/@Suite/Tag), parameterized and
async/throws test functions in both frameworks, XCUITest
(XCUIApplication/XCUIElement), and XCTestExpectation for
callback-based asynchronous code -- not performance testing, Test Plans,
snapshot testing, UI test recording, mocking/DI patterns, or accessibility
audits.
Routing
Load only the contracts relevant to the task. All paths relative to knowledge/testing/.
- Subclassing
XCTestCase; naming atest-prefixed method; overridingsetUp()/setUpWithError()/tearDown()/tearDownWithError(); usingXCTAssertEqual/XCTAssertTrue/XCTAssertNil/XCTAssertThrowsError/XCTFail; or skipping withXCTSkip/XCTSkipIf/XCTSkipUnless-> xctest-case-structure-and-assertions.md - Writing
import Testing; declaring@Test; choosing between#expect(_:)and#require(_:); grouping with@Suite; or tagging withTag/.tags(_:)-> swift-testing-fundamentals.md - Parameterizing a
@Testwitharguments:over one collection, two collections, orzip(...); or writing anasync/async throwstest function in either framework -> parameterized-and-async-tests.md - Launching the app under test with
XCUIApplication()/.launch(); settingcontinueAfterFailure; queryingXCUIElements byaccessibilityIdentifier; or asserting with.exists/.waitForExistence(timeout:)-> ui-testing-with-xcuiapplication.md - Testing a delegate callback or completion-handler API with no
async/awaitentry point viaXCTestExpectation,expectation(description:),.fulfill(), orawait fulfillment(of:timeout:)-> expectations-for-asynchronous-code.md
Never load more than the contracts relevant to the specific question.
Stop Conditions
Stop and report if the requested topic has no matching Knowledge Contract
in knowledge/testing/ -- do not guess or fall back to general knowledge.
Performance testing (measure { }, XCTMetric, XCTClockMetric) is out
of scope entirely -- do not fabricate performance-testing guidance. Xcode
Test Plans (.xctestplan) and code coverage configuration are owned by
the xcode domain -- report the boundary rather than answer from this
skill. Snapshot testing (e.g. swift-snapshot-testing) is a third-party
pattern, not an Apple-documented API -- out of scope entirely. Xcode's UI
test recording is an IDE workflow, not an API surface -- out of scope
entirely. Mocking, dependency injection, and test-double patterns are
general software-engineering technique, not Apple-API-specific -- out of
scope entirely. XCUIApplication().performAccessibilityAudit() is owned
by the accessibility domain -- report the boundary rather than build it
here.