Write tests, add test coverage, unit test, or add missing tests for Bitwarden iOS. Use when asked to "write tests", "add test coverage", "test this", "unit test", "add tests for", "missing tests", or when creating test files for new implementations.
npx skills add https://github.com/bitwarden/ios --skill testing-ios-code
Use this skill to write tests following Bitwarden iOS patterns.
Read Docs/Testing.md — it is the authoritative source for test structure, naming, templates, decision matrix, and simulator configuration.
| Scenario | Framework | Why |
|----------|-----------|-----|
| New test file | Swift Testing | Preferred for all new tests |
| Existing XCTest file | XCTest | Don't mix frameworks in one file |
| ViewInspector tests | XCTest | ViewInspector requires XCTest |
| Snapshot tests | XCTest | SnapshotTesting requires BitwardenTestCase |
Choose the right test type based on what you're testing:
| What | Test type | XCTest example | Swift Testing example |
|------|-----------|----------------|----------------------|
| Processor actions/effects/state | Unit test | examples/processor-test-example.md | examples/processor-test-swift-testing-example.md |
| Coordinator navigation/routes | Unit test | examples/coordinator-test-example.md | examples/coordinator-test-swift-testing-example.md |
| View interactions (buttons, toggles) | ViewInspector test | examples/view-test-example.md | — (use XCTest) |
| View appearance | Snapshot test (disabletest_ prefix) | examples/view-test-example.md | — (use XCTest) |
| Service/repository business logic | Unit test | examples/service-test-example.md | examples/service-test-swift-testing-example.md |
Use a struct with init() — no teardown needed, value types are discarded after each test:
@MainActor
struct FeatureProcessorTests {
let coordinator: MockCoordinator<FeatureRoute, FeatureEvent>
let services: MockServiceContainer
let subject: FeatureProcessor
init() {
coordinator = MockCoordinator()
services = ServiceContainer.withMocks()
subject = FeatureProcessor(
coordinator: coordinator.asAnyCoordinator(),
services: services,
state: FeatureState(),
)
}
}
Use a class subclassing BitwardenTestCase with setUp()/tearDown():
class FeatureProcessorTests: BitwardenTestCase {
var coordinator: MockCoordinator<FeatureRoute, FeatureEvent>!
var services: MockServiceContainer!
var subject: FeatureProcessor!
override func setUp() {
super.setUp()
coordinator = MockCoordinator()
services = ServiceContainer.withMocks()
subject = FeatureProcessor(
coordinator: coordinator.asAnyCoordinator(),
services: services,
state: FeatureState(),
)
}
override func tearDown() {
super.tearDown()
coordinator = nil
services = nil
subject = nil
}
}
See examples/ for complete patterns per test type.
| Framework | Pattern | Example |
|-----------|---------|---------|
| Swift Testing | @Test func <functionName>_<behavior>() | @Test func perform_appeared_loadsData() async |
| XCTest | func test_<functionName>_<behavior>() | func test_perform_appeared_loadsData() async |
| XCTest | Swift Testing |
|--------|---------------|
| XCTAssertEqual(a, b) | #expect(a == b) |
| XCTAssertTrue(x) | #expect(x == true) or #expect(x) |
| XCTAssertNil(x) | #expect(x == nil) |
| XCTAssertNotNil(x) | #expect(x != nil) |
| XCTUnwrap(x) | try #require(x) |
| XCTAssertThrowsError | #expect(throws:) { ... } |
Processor tests — test both paths:
receive(_:) actions: assert subject.state mutationsperform(_:) effects: await subject.perform(.effect), then assert state or coordinator callsService tests — test:
View tests — test (XCTest only):
processor.dispatchedActions.last (sync)processor.effects.lastTest files must live alongside implementation files:
BitwardenShared/UI/Auth/Login/LoginProcessor.swift
BitwardenShared/UI/Auth/Login/LoginProcessorTests.swift ← same directory
New protocols need mocks:
// sourcery: AutoMockable as a trailing comment on the protocol declaration line./Scripts/generate-mocks.sh <Framework> where <Framework> matches the target (e.g. BitwardenShared, AuthenticatorShared, BitwardenKit, AuthenticatorBridgeKit) — requires BUILD_DIR, see script headerSee references/mock-generation.md for full details.
CipherView fixtures belong in the shared BitwardenSdk+<Area>Fixtures.swift file for the domain the model belongs to (e.g. CipherView.cardFixture()), not co-located inside an individual test file. Pick the file by area and framework: Vault models go in …/UI/Vault/PreviewContent/BitwardenSdk+VaultFixtures.swift, Auth models in …/Core/Auth/Services/TestHelpers/BitwardenSdk+AuthFixtures.swift, Tools models in …/Core/Tools/Extensions/TestHelpers/BitwardenSdk+ToolsFixtures.swift, and so on — under BitwardenShared for Password Manager or the AuthenticatorShared counterpart for Authenticator. Add new reusable fixtures to the matching file (create the area's fixtures file if one doesn't exist yet).<Type>Tests+<Feature>.swift extensions (e.g. AddEditItemProcessorTests+DriversLicense.swift), and author the new file in Swift Testing.MockProcessor/Store in setUp, then assertSnapshot(of: subject.navStackWrapped, as:) per state (all prefixed disabletest_); see AddEditSendItemView+SnapshotTests.swift. This is required for new views, which use #Preview macros that the snapshot harness cannot enumerate. (2) Iterate PreviewProvider._allPreviews, which is sometimes the better path for views that still expose a PreviewProvider. When a view could go either way, use the AskUserQuestion tool to let the user choose rather than deciding unilaterally — offer (a) instantiate the view directly and (b) iterate PreviewProvider._allPreviews, noting that direct instantiation is required if the view only exposes #Preview macros.Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
Use when implementing any feature or bugfix, before writing implementation code
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating quantitative trading strategies. Covers "beating ideas to death" methodology, parameter robustness testing, slippage modeling, bias prevention, and interpreting backtest results. Applicable when user asks about backtesting, strategy validation, robustness testing, avoiding overfitting, or systematic trading development.
Cloud laboratory platform for automated protein testing and validation. Use when designing proteins and needing experimental validation including binding assays, expression testing, thermostability measurements, enzyme activity assays, or protein sequence optimization. Also use for submitting experiments via API, tracking experiment status, downloading results, optimizing protein sequences for better expression using computational tools (NetSolP, SoluProt, SolubleMPNN, ESM), or managing protein design workflows with wet-lab validation.
This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.
Take bitwarden/testing-ios-code from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.