ChappieSDKTesting library target that provides seeded auth fixtures and an in-memory credential store for unit and UI tests. Keep it out of your app target — link it only to test targets so test-only code never ships to production.
Adding ChappieSDKTesting to your test target
Add the package dependency and link bothChappieSDK and ChappieSDKTesting to your test target in Package.swift:
ChappieSDKRuntime to the same target:
Never link
ChappieSDKTesting from your app target. It is designed exclusively for test and UI-test targets — linking it to your app would bundle test fixtures and Keychain helpers into your production binary.Seeding a signed-in session
CallChappieTestAuth.seedSignedInSession() at the start of a test to write a fake-but-valid credential into the Keychain so ChappieAuthSession starts in the .signedIn state without requiring a real OAuth flow:
| Field | Value |
|---|---|
preview@example.com | |
| User ID | user_test |
| Account ID | account_test |
| Plan | plus |
| Expiry | One hour from now |
Customising the seeded account
Pass aChappieAccountInfo to override any account metadata fields:
keychainService when the app under test uses a non-default service name:
Clearing a seeded session
CallChappieTestAuth.clearSession() in your test tear-down to remove the seeded credential and return the app to a signed-out state:
Using ChappieInMemoryThreadStore in unit tests
For unit tests that exercise conversation storage without touching the filesystem, useChappieInMemoryThreadStore from ChappieSDKRuntime. It implements the full ChappieThreadStore protocol in memory and applies the same retention logic as ChappieFileThreadStore:
now closure to test time-dependent retention behaviour without sleeping:
UI tests: resetting auth state via launch arguments
The demo app pattern shows how to handle auth state in UI tests using launch arguments. In your app’s@main entry point, check for the -resetChappieAuthForUITests launch argument (in a #if DEBUG block) and call ChappieTestAuth.clearSession() before creating the auth session:
XCUIApplication setup in the UI test target:
-seedChappieAuthForUITests to start UI tests in the signed-in state without going through the actual OAuth flow.
Running the SDK’s test suite
Run all Swift package tests from theChappieSDK directory: