Back to Skills

ios-generate-unit-tests

verified

Generate comprehensive unit tests for iOS RxSwift project files (ViewModels, UseCases, Services). Creates complete test files with nested mocks, RxTest patterns, session error handling, and memory leak tests. Use when "generate unit tests", "write tests for", "create unit tests", "add tests for", or analyzing Swift files in PayooMerchant project.

View on GitHub

Marketplace

py-claude-marketplace

daispacy/py-claude-marketplace

Plugin

py-plugin

Repository

daispacy/py-claude-marketplace

py-plugin/skills/ios-generate-unit-tests/SKILL.md

Last Verified

January 20, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/daispacy/py-claude-marketplace/blob/main/py-plugin/skills/ios-generate-unit-tests/SKILL.md -a claude-code --skill ios-generate-unit-tests

Installation paths:

Claude
.claude/skills/ios-generate-unit-tests/
Powered by add-skill CLI

Instructions

# iOS RxSwift Unit Test Generator

Automatically generate comprehensive unit tests for iOS RxSwift project following Clean Architecture patterns.

## When to Activate

- "generate unit tests for [file]"
- "write tests for [ViewModel/UseCase/Service]"
- "create unit tests for this file"
- "add tests for [class name]"
- "test [file path]"

## Process

### 1. Identify Target File

**Ask user for file to test** (if not provided):
```
Which file would you like to generate tests for?
Provide the file path or class name (e.g., BalanceInformationViewModel.swift)
```

**Read target file** and determine type:
- ViewModel: Has `ViewModelType`, `Input`, `Output`, `transform` method
- UseCase: Implements `*UseCaseType` protocol
- Service: Implements service protocol

### 2. Read Testing Guide

**CRITICAL**: Read the comprehensive testing guide:
```
~/Library/Application Support/Code/User/prompts/ios-mc-generate-unit-test.prompt.md
```

This guide contains ALL rules, patterns, and examples to follow.

### 3. Analyze Target File

**Extract from target file:**
- Class name and type (ViewModel/UseCase/Service)
- All dependencies (injected in initializer)
- Protocol types for each dependency
- Public methods and their signatures
- Input/Output structure (for ViewModels)
- Observable/Single/Completable return types

**Search for protocol definitions** if needed:
```bash
Glob: **/*UseCaseType.swift
Grep: "protocol [DependencyName]"
```

### 4. Generate Test File

**Create complete test file** at:
```
PayooMerchantTests/[appropriate-folder]/[ClassName]Tests.swift
```

**Folder structure:**
- ViewModels → `PayooMerchantTests/ViewModel/`
- UseCases → `PayooMerchantTests/UseCase/`
- Services → `PayooMerchantTests/Mock/Service/`

**Test file MUST include:**

1. **Required imports**:
   ```swift
   import XCTest
   import RxSwift
   import RxCocoa
   import RxTest
   import RxBlocking
   import Domain
   @testable import PayooMerchant
   ```

2. **Test class with nested mocks**:
   - ALL moc

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
6326 chars