Skills

Test Generator

Generate test templates for unit tests, integration tests, and UI tests using Swift...

Install

npx skills add rshankras/claude-code-apple-skills --skill test-generator -g -a claude-code -y
Category
Design
Updated
3mo ago
License
MIT
Context cost
Mediumabout 2,634 tokens
Runs scripts
No, instructions only

What it does

Generate test templates for unit tests, integration tests, and UI tests using Swift Testing and XCTest. Use when adding tests to iOS/macOS apps.

Test Generator

Generate test templates for unit tests, integration tests, and UI tests in iOS/macOS apps.

When This Skill Activates

Use this skill when the user:

  • Asks to "add tests" or "write tests" for their app
  • Asks about unit testing, UI testing, or XCTest
  • Wants to test ViewModels, services, or repositories
  • Mentions TDD or test-driven development
  • Asks about Swift Testing framework (@Test, #expect, @Suite)
  • Wants mock objects or test helpers
  • Asks about snapshot testing or preview tests

Decision Tree

What tests do you need?
|
+-- Unit tests for business logic
|   +-- Swift Testing (@Test, #expect) -- recommended for iOS 16+
|   +-- XCTest -- for iOS 13-15 support or existing XCTest projects
|
+-- Integration tests (component interactions)
|   +-- Protocol-based mocks with dependency injection
|
+-- UI tests
|   +-- XCUITest with Screen Object pattern
|
+-- Snapshot/preview tests
    +-- PreviewSnapshots or swift-snapshot-testing

Pre-Generation Checks

1. Project Context Detection

  • Identify existing test targets and test runner
  • Detect testing framework already in use (Swift Testing vs XCTest)
  • Verify deployment target (Swift Testing requires iOS 16+ / macOS 13+)
  • Identify project architecture pattern (MVVM, TCA, Repository, etc.)
  • Locate source file directories

2. Conflict Detection

Search for existing test infrastructure:

Glob: **/*Tests.swift, **/*Tests/**/*.swift, **/*Spec.swift
Grep: "import XCTest" or "import Testing" or "@Suite" or "@Test"
Grep: "MockItemRepository" or "protocol.*Repository" or "class Mock"

If existing tests are found:

  • Ask user whether to follow the existing framework (XCTest vs Swift Testing) or migrate
  • Check for existing mock objects to reuse or extend
  • Identify existing test helpers and factories
Read the whole SKILL.md on GitHub

More in Design