test-generator
Skill777 starsChanged 5 months agoMITView on GitHub
Generate test templates for unit tests, integration tests, and UI tests using Swift Testing and XCTest. Use when adding tests to iOS/macOS apps.
21 other projects use a version of this.
Adopted by
Most recently taken up by
- jablonkai/skillstheir own version, first seen Oct 1, 2026
- u9401066/pubmed-search-mcptheir own version, first seen Oct 1, 2026
- trebaud/skillstheir own version, first seen Aug 18, 2026
- codebygarv/Ai-skillstheir own version, first seen Aug 16, 2026
- liuxiao20051106-prog/claude-skillstheir own version, first seen Aug 10, 2026
- bestdeejay-design/agent-skillstheir own version, first seen Aug 9, 2026
Used with
Projects with it also use git-doc-updater, git-precommit and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
u9401066Skillgit-doc-updater
Auto-check and update key documentation before Git commits to keep docs in sync with code. Triggers: docs, 文檔, 更新文檔, sync docs, release, 發布.
Also in 3 projects that use this
u9401066Skillgit-precommit
Orchestrate pre-commit workflow including Memory Bank sync, README/CHANGELOG/ROADMAP updates. Triggers: GIT, gc, push, commit, 提交, 準備 commit, 要提交了, git commit, pre-commit, 推送.
Also in 3 projects that use this
nilecuiSkillcode-refactor
Perform bulk code refactoring operations like renaming variables/functions across files, replacing patterns, and updating API calls. Use when users request renaming identifiers, replacing deprecated code patterns, updating method calls, or making consistent changes across multiple locations.
Also in 3 projects that use this
AutumnsGroveSkillapi-designer
Design and document RESTful and GraphQL APIs with OpenAPI/Swagger specifications, authentication patterns, versioning strategies, and best practices. Use for: (1) Creating API specifications, (2) Designing REST endpoints, (3) GraphQL schema design, (4) API authentication and authorization, (5) API versioning strategies, (6) Documentation generation
Also in 3 projects that use this
ArogyaReddySkillchangelog-generator
Automatically creates user-facing changelogs from git commits by analyzing commit history, categorizing changes, and transforming technical commits into clear, customer-friendly release notes. Turns hours of manual changelog writing into minutes of automated generation.
Also in 4 projects that use this
- +7 more from u9401066
Other versions21 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 21
- laolaoshiren/claude-code-skills-zh★ 876same name
- alirezarezvani/claude-code-tresor★ 777same name
- u9401066/pubmed-search-mcp★ 28same name
- codebygarv/Ai-skills★ 26same name
- benshapyro/cadre-devkit-claude★ 9same name
- bestdeejay-design/agent-skills★ 5same name
- Data-Wise/craft★ 4same name
- u9401066/nsforge-mcp★ 4same name
- agentsdance/agentskills★ 3same name
- suxiao1824308603/Qoder-devtools-skills★ 3same name
11 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository183 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- app-intentsSkill
- foundation-modelsSkill
- apple-intelligenceSkill
- visual-intelligenceSkill
- ad-attributionSkill
- app-description-writerSkill
- apple-search-adsSkill
- iap-finalizerSkill
- keyword-optimizerSkill
- marketing-strategySkill
- originality-checkSkill
- ratings-mechanicsSkill
- rejection-handlerSkill
- review-response-writerSkill
- screenshot-plannerSkill
- app-storeSkill
- web-presenceSkill
- core-mlSkill
- animation-patternsSkill
- game-feelSkill
- liquid-glassSkill
- sf-symbolsSkill
- designSkill
- typographySkill
- ui-prototypingSkill
- ux-writingSkill
- attributed-stringSkill
- foundationSkill
- accessibility-generatorSkill
- account-deletionSkill
- analytics-setupSkill
- announcement-bannerSkill
- app-clipSkill
- app-extensionsSkill
- app-icon-generatorSkill
- app-store-assetsSkill
- auth-flowSkill
- background-processingSkill
- ci-cd-setupSkill
- cloudkit-syncSkill
- consent-flowSkill
- custom-product-pagesSkill
- data-exportSkill
- debug-menuSkill
- deep-linkingSkill
- error-monitoringSkill
- feature-flagsSkill
- featuring-nominationSkill
- feedback-formSkill
- force-updateSkill
- http-cacheSkill
- image-loadingSkill
- in-app-eventsSkill
- lapsed-userSkill
- live-activity-generatorSkill
- localization-setupSkill
- logging-setupSkill
- milestone-celebrationSkill
- networking-layerSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. 0 are common, 13 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 13 edited versions we read keep these.
13
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Use this skill when the user:
- Distinctive: line 54
Search for existing test infrastructure:
- Distinctive: line 61
If existing tests are found:
- Distinctive: line 62
Ask user whether to follow the existing framework (XCTest vs Swift Testing) or migrate
- Distinctive: line 63
Check for existing mock objects to reuse or extend
- Distinctive: line 66
If a test target already exists:
- Distinctive: line 67
Add new tests to the existing target -- do NOT create a new target
- Distinctive: line 68
Follow the existing directory structure and naming conventions
- Distinctive: line 86
Unit Tests: - Test individual components in isolation
- Distinctive: line 87
Integration Tests: - Test component interactions
- Distinctive: line 88
UI Tests: - Test user interface and flows
- Distinctive: line 354
Keep tests fast: - No real network/disk
- Distinctive: line 368
Before finishing test generation, verify:
“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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-testingPre-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
If a test target already exists:
- Add new tests to the existing target -- do NOT create a new target
- Follow the existing directory structure and naming conventions
3. Architecture Detection
Grep: "ViewModel" or "Reducer" or "UseCase" or "Repository" or "Service"
Glob: **/*ViewModel.swift, **/*Reducer.swift, **/*Repository.swiftThis determines which test templates to generate (ViewModel tests, Reducer tests, etc.).
Configuration Questions
1. Testing Framework
- Swift Testing (Recommended, iOS 16+) - Modern, expressive syntax
- XCTest - Traditional framework, all iOS versions
- Both - Mix of frameworks
2. Test Types to Generate
- Unit Tests - Test individual components in isolation
- Integration Tests - Test component interactions
- UI Tests - Test user interface and flows
- All - Complete test coverage
3. Architecture Pattern
- MVVM - ViewModel tests
- TCA - Reducer tests
- Repository - Data layer tests
- Custom - Based on project structure
Generated Files
Unit Tests
Tests/UnitTests/
├── ViewModelTests/
│ └── ItemViewModelTests.swift
├── ServiceTests/
│ └── APIClientTests.swift
└── RepositoryTests/
└── ItemRepositoryTests.swiftUI Tests
Tests/UITests/
├── Screens/
│ └── HomeScreenTests.swift
├── Flows/
│ └── OnboardingFlowTests.swift
└── Helpers/
└── TestHelpers.swiftSwift Testing (Modern)
Basic Test Structure
import Testing
@testable import YourApp
@Suite("Item ViewModel Tests")
struct ItemViewModelTests {
@Test("loads items successfully")
func loadsItems() async throws {
let mockRepository = MockItemRepository()
let viewModel = ItemViewModel(repository: mockRepository)
await viewModel.loadItems()
#expect(viewModel.items.count == 3)
#expect(viewModel.isLoading == false)
}
@Test("handles empty state")
func handlesEmptyState() async {
let mockRepository = MockItemRepository(items: [])
let viewModel = ItemViewModel(repository: mockRepository)
await viewModel.loadItems()
#expect(viewModel.items.isEmpty)
#expect(viewModel.showEmptyState)
}
}Parameterized Tests
@Test("validates email format", arguments: [
("valid@email.com", true),
("invalid", false),
("no@tld", false),
("test@domain.co.uk", true)
])
func validatesEmail(email: String, isValid: Bool) {
#expect(EmailValidator.isValid(email) == isValid)
}XCTest (Traditional)
Basic Test Structure
import XCTest
@testable import YourApp
final class ItemViewModelTests: XCTestCase {
var sut: ItemViewModel!
var mockRepository: MockItemRepository!
override func setUp() {
super.setUp()
mockRepository = MockItemRepository()
sut = ItemViewModel(repository: mockRepository)
}
override func tearDown() {
sut = nil
mockRepository = nil
super.tearDown()
}
func testLoadsItems() async throws {
await sut.loadItems()
XCTAssertEqual(sut.items.count, 3)
XCTAssertFalse(sut.isLoading)
}
}Test Patterns
Testing ViewModels
@Suite("ViewModel Tests")
struct ViewModelTests {
@Test("state transitions correctly")
func stateTransitions() async {
let vm = ItemViewModel(repository: MockItemRepository())
#expect(vm.state == .idle)
await vm.loadItems()
#expect(vm.state == .loaded)
}
@Test("error handling")
func errorHandling() async {
let failingRepo = MockItemRepository(shouldFail: true)
let vm = ItemViewModel(repository: failingRepo)
await vm.loadItems()
#expect(vm.state == .error)
#expect(vm.errorMessage != nil)
}
}Testing Async Code
@Test("fetches data asynchronously")
func fetchesData() async throws {
let service = APIService()
let result = try await service.fetchItems()
#expect(result.count > 0)
}
@Test("times out appropriately")
func timesOut() async {
await #expect(throws: TimeoutError.self) {
try await withTimeout(seconds: 1) {
try await Task.sleep(for: .seconds(5))
}
}
}Mock Creation
Protocol-Based Mocks
protocol ItemRepository {
func fetchItems() async throws -> [Item]
func saveItem(_ item: Item) async throws
}
final class MockItemRepository: ItemRepository {
var items: [Item] = []
var shouldFail = false
var saveCallCount = 0
func fetchItems() async throws -> [Item] {
if shouldFail {
throw TestError.mockFailure
}
return items
}
func saveItem(_ item: Item) async throws {
saveCallCount += 1
items.append(item)
}
}UI Testing
Screen Object Pattern
import XCTest
final class HomeScreen {
let app: XCUIApplication
init(app: XCUIApplication) {
self.app = app
}
var itemList: XCUIElement {
app.collectionViews["itemList"]
}
var addButton: XCUIElement {
app.buttons["addItem"]
}
func tapItem(at index: Int) {
itemList.cells.element(boundBy: index).tap()
}
func addNewItem(title: String) {
addButton.tap()
app.textFields["itemTitle"].tap()
app.textFields["itemTitle"].typeText(title)
app.buttons["save"].tap()
}
}Integration Steps
1. Add Test Target
In Xcode:
- File > New > Target
- Choose "Unit Testing Bundle" or "UI Testing Bundle"
- Name appropriately (e.g.,
YourAppTests)
2. Configure Test Scheme
- Edit Scheme > Test
- Add test targets
- Configure code coverage
3. Run Tests
# Command line
xcodebuild test -scheme YourApp -destination 'platform=iOS Simulator,name=iPhone 16'
# With coverage
xcodebuild test -scheme YourApp -enableCodeCoverage YESBest Practices
- Test one thing per test - Clear, focused tests
- Use descriptive names - Tests as documentation
- Arrange-Act-Assert - Clear test structure
- Mock external dependencies - Isolate units
- Test edge cases - Empty, nil, error states
- Keep tests fast - No real network/disk
Top 5 Mistakes
| # | Mistake | Why It's Wrong | Fix |
| 1 | Testing implementation details instead of behavior | Tests break on every refactor, providing no safety net | Test public API and observable outcomes, not internal state |
| 2 | Sharing mutable state between tests | Tests pass individually but fail when run together (order-dependent) | Create fresh instances in each test; use init() in @Suite structs or setUp() in XCTest |
| 3 | Using XCTAssertTrue(result != nil) instead of XCTUnwrap | Failure message is useless ("XCTAssertTrue failed") with no context | Use let value = try XCTUnwrap(result) or #expect(result != nil) with Swift Testing |
| 4 | Not testing error paths | Only happy-path coverage; errors crash in production | Always test with shouldFail = true mocks and verify error state |
| 5 | Real network calls in unit tests | Tests are slow, flaky, and fail offline | Use protocol-based mocks; reserve real network calls for integration test schemes |
Review Checklist
Before finishing test generation, verify:
- Naming: Test names describe the behavior, not the method (
loadsItemsSuccessfullynottestLoadItems) - Isolation: Each test creates its own dependencies -- no shared mutable state
- No real I/O: Unit tests use mocks for network, disk, and database
- Async handling: Async tests use
async throws(Swift Testing) orasync throwswith expectations (XCTest) - Error paths tested: At least one test per function verifies error/failure behavior
- Edge cases: Empty collections, nil optionals, boundary values are tested
- Assertions are specific: Using
#expect(items.count == 3)not#expect(!items.isEmpty) - Mock call verification: Mocks track call counts and received arguments where needed
- No force unwraps in tests: Use
try #require()(Swift Testing) orXCTUnwrap(XCTest) - Tests compile and run: Verify with
xcodebuild testor Xcode test navigator
References
- templates.md -- Production-ready code templates for test suites, mocks, and helpers
- Swift Testing
- XCTest Framework
- Testing Your Apps in Xcode
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

