Skip to content

[PM-33573] llm: Add testing-ios-code skill with examples and references#2447

Merged
SaintPatrck merged 2 commits intomainfrom
llm/testing-ios-code
Apr 8, 2026
Merged

[PM-33573] llm: Add testing-ios-code skill with examples and references#2447
SaintPatrck merged 2 commits intomainfrom
llm/testing-ios-code

Conversation

@SaintPatrck
Copy link
Copy Markdown
Contributor

@SaintPatrck SaintPatrck commented Mar 13, 2026

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-33573

📔 Objective

Adds a Claude skill for writing tests in Bitwarden iOS, with concrete examples derived from real codebase test files. Covers both XCTest (legacy, still widely used) and Swift Testing (preferred for new tests).

What changed:

  • skills/testing-ios-code/SKILL.md — Framework selection guide (Swift Testing for new files, XCTest for existing/ViewInspector/snapshots), decision table for choosing test type, setup patterns for both frameworks (struct+init() vs BitwardenTestCase+setUp/tearDown), naming conventions, assertion mapping table, co-location rule, and mock generation reference. Defers to Docs/Testing.md as authoritative.

  • examples/ — Seven concrete examples based on actual codebase test files:

    • XCTest: processor, coordinator, view (ViewInspector + snapshots), service
    • Swift Testing: processor, coordinator, service — using struct/init(), @Test, #expect, #require
  • references/testing-gotchas.md — Non-obvious facts: disabletest_ prefix (XCTest-only, with Swift Testing traits note), simulator device/OS requirements, BitwardenTestError (correct path: TestHelpers/Support/, correct conformance: Equatable, LocalizedError), randomized test execution order, @MainActor requirement on async processor tests.

  • references/mock-generation.md — Sourcery AutoMockable workflow: inline annotation format (trailing comment on protocol line), manual trigger commands for all four frameworks (including AuthenticatorBridgeKit), generated file locations, ServiceContainer.withMocks pattern.

  • Docs/Testing.md — Adds Swift Testing examples alongside XCTest in processor and coordinator sections, framework selection guidance, Swift Testing quick reference patterns, and split test checklist (general/XCTest/Swift Testing).

  • CLAUDE.md — Updates the Testing section from a verbose directive to a concise pointer to Docs/Testing.md + testing-ios-code skill. Also corrects the snapshot prefix from disable to disabletest_.

@github-actions github-actions bot added the t:llm Change Type - LLM related change (e.g. CLAUDE.md files) label Mar 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 13, 2026

Logo
Checkmarx One – Scan Summary & Detailsc7eca51b-0404-4904-b0e6-08a41f320898

Great job! No new security vulnerabilities introduced in this pull request

@SaintPatrck SaintPatrck added the ai-review Request a Claude code review label Mar 13, 2026
@claude
Copy link
Copy Markdown

claude bot commented Mar 13, 2026

Claude finished @SaintPatrck's task in 5m 16s —— View job


I'll analyze this and get back to you.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.96%. Comparing base (262e93f) to head (07dcf4f).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2447      +/-   ##
==========================================
- Coverage   87.09%   85.96%   -1.14%     
==========================================
  Files        1859     2089     +230     
  Lines      164348   179153   +14805     
==========================================
+ Hits       143134   154002   +10868     
- Misses      21214    25151    +3937     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@claude
Copy link
Copy Markdown

claude bot commented Mar 13, 2026

test

@claude
Copy link
Copy Markdown

claude bot commented Mar 13, 2026

Overall Assessment: APPROVE

Reviewed the new testing-ios-code skill (SKILL.md, 4 examples, 2 references) and the CLAUDE.md update. The skill is well-structured with accurate examples that match real codebase patterns verified against actual test files (LandingProcessorTests.swift, AuthCoordinatorTests.swift, LandingView+ViewInspectorTests.swift). The CLAUDE.md fix correcting the snapshot prefix from disable to disabletest_ is accurate.

Code Review Details
  • ⚠️ IMPORTANT: BitwardenTestError file location is incorrect -- testing-gotchas.md line 33 says the type is in GlobalTestHelpers/ but it actually lives in TestHelpers/Support/BitwardenTestError.swift. An LLM following this skill would look in the wrong directory. Additionally, the protocol conformance shown (Error, Equatable) differs from the actual declaration (Equatable, LocalizedError).

    • .claude/skills/testing-ios-code/references/testing-gotchas.md:33
  • ⚠️ IMPORTANT: Confusing wrong-prefix example contradicts itself -- testing-gotchas.md lines 18-21 have a block labeled with a wrong-prefix marker that contains func disabletest_snapshot_empty() { ... } immediately followed by a comment saying "This is actually correct". This contradicts the block label and will confuse the LLM. Suggest removing the redundant correct example from the wrong-prefix block and keeping only func disable_snapshot_empty() { ... } as the wrong example.

    • .claude/skills/testing-ios-code/references/testing-gotchas.md:18-21

Copy link
Copy Markdown
Contributor

@KatherineInCode KatherineInCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 We may want to re-do these example files to be Swift Testing, rather than XCTest. That's something that's still very much in slow transition, though


## Annotation

Add `// sourcery: AutoMockable` above any protocol that needs a mock:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 This goes inline:

protocol FeatureService: AnyObject { // sourcery: AutoMockable

# For BitwardenKit
mint run sourcery --config BitwardenKit/Sourcery/sourcery.yml
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 AuthenticatorBridgeKit should also be in these lists


## Snapshot Tests Are Globally Disabled

Snapshot test function names must be prefixed with `disabletest_` (not `test_`).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 As we move into Swift Testing, I believe we actually want to accomplish this through traits.

description: 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.
---

# Testing iOS Code
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 We are currently in the process of migrating from XCTest to Swift Testing. We probably want to update the skill to differentiate between the two—new test files should be Swift Testing if possible, but old files should remain XCTest for now (though at some point we may want to more formally write a skill for conversion). However, if there are things that Swift Testing can't do yet, we should default back to XCTest.

I'm not sure if that information would be here in the skill, or should actually be in the Testing.md file? 🤔

- SKILL.md: test type decision table, setup pattern with BitwardenTestCase and
  ServiceContainer.withMocks, naming convention, co-location rule, mock
  generation reference; references Docs/Testing.md as authoritative
- examples/processor-test-example.md: full processor test with setUp/tearDown,
  action test (state mutation), effect test (async), error path test
- examples/coordinator-test-example.md: MockStackNavigator, route assertions,
  action.type and action.view verification, child coordinator start check
- examples/view-test-example.md: MockProcessor, ViewInspector button/toggle
  tests, dispatchedActions vs effects, snapshot test with disabletest_ prefix
- examples/service-test-example.md: DefaultXxx with direct mock injection,
  success/error/side-effect tests, assertAsyncThrows pattern
- references/testing-gotchas.md: disabletest_ prefix, simulator requirements,
  BitwardenTestError, randomized execution order, @mainactor requirement
- references/mock-generation.md: AutoMockable annotation, Sourcery commands,
  generated file locations, ServiceContainer.withMocks pattern
- CLAUDE.md: update Testing section to pointer + correct disabletest_ prefix
@SaintPatrck SaintPatrck force-pushed the llm/testing-ios-code branch from dd9afff to 07dcf4f Compare April 8, 2026 16:44
@github-actions github-actions bot added the t:docs Change Type - Documentation label Apr 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the new testing-ios-code skill (SKILL.md, 7 examples, 2 references), updates to Docs/Testing.md adding Swift Testing examples and framework selection guidance, and the CLAUDE.md testing section update. All examples and references were validated against the actual codebase: BitwardenTestError location and conformance, disabletest_ snapshot prefix, AutoMockable inline annotation format, Swift Testing struct/init pattern, and ServiceContainer.withMocks() usage all match real codebase patterns. The latest commit addresses prior review feedback (Swift Testing support, AuthenticatorBridgeKit inclusion, corrected AutoMockable format).

Code Review Details

No findings. The skill content accurately reflects codebase conventions and patterns.

@SaintPatrck
Copy link
Copy Markdown
Contributor Author

@KatherineInCode great feedback. I've moved the informational details to Testing.md for human and LLM awareness, and updated Claude's files to include instructions/examples for Swift Tests. Also provided some guidance on when to use which framework based on your comments. 🚀

@SaintPatrck SaintPatrck marked this pull request as ready for review April 8, 2026 17:03
@SaintPatrck SaintPatrck requested review from a team and matt-livefront as code owners April 8, 2026 17:03
@SaintPatrck SaintPatrck enabled auto-merge (squash) April 8, 2026 17:03
@SaintPatrck SaintPatrck removed the t:docs Change Type - Documentation label Apr 8, 2026
@SaintPatrck SaintPatrck merged commit c50fa73 into main Apr 8, 2026
21 of 22 checks passed
@SaintPatrck SaintPatrck deleted the llm/testing-ios-code branch April 8, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review t:llm Change Type - LLM related change (e.g. CLAUDE.md files)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants