Skip to main content

Overview

Parsaa generates unit tests for your Swift code. Summon it with the @tester mention in the composer, with a file focused in Xcode. It identifies testable behaviors, edge cases, and error conditions, then writes tests to your test target.
@tester is a built-in sub-agent. Configure it in Settings → Automation → Test Generator: choose the framework (Swift Testing or XCTest), the naming convention, whether to generate mocks, and a coverage target — those settings are passed to the agent on each run.

What It Generates

Test Cases

XCTestCase subclasses with well-structured test methods covering the behavior of your code.

Setup & Teardown

setUp() and tearDown() methods that initialize and clean up test dependencies.

Edge Case Tests

Tests for boundary conditions, empty inputs, nil values, and other edge cases your code should handle.

Mocks & Stubs

Mock objects and stubs for dependencies, so your tests are isolated and repeatable.

How to Use

1

Enable the generator

Turn on Test Generator in Settings → Automation → Test Generator and pick your framework and options.
2

Focus the file in Xcode

Open the file you want covered so it becomes the focused file.
3

Mention @tester

In the Parsaa composer, type @tester. Parsaa generates tests for the focused file and writes them to disk.
4

Review & add to your target

Review the generated tests, add the file to your test target, and run them to verify they pass.

Example

Input — a function to test:
struct PriceCalculator {
    func calculateTotal(items: [Item], taxRate: Double) -> Double {
        let subtotal = items.reduce(0.0) { $0 + $1.price }
        let tax = subtotal * taxRate
        return subtotal + tax
    }
}
Generated tests:
import XCTest
@testable import MyApp

final class PriceCalculatorTests: XCTestCase {

    var calculator: PriceCalculator!

    override func setUp() {
        super.setUp()
        calculator = PriceCalculator()
    }

    func testCalculateTotal_withMultipleItems() {
        let items = [
            Item(name: "A", price: 10.0),
            Item(name: "B", price: 20.0)
        ]
        let total = calculator.calculateTotal(items: items, taxRate: 0.1)
        XCTAssertEqual(total, 33.0, accuracy: 0.01)
    }

    func testCalculateTotal_withEmptyItems() {
        let total = calculator.calculateTotal(items: [], taxRate: 0.1)
        XCTAssertEqual(total, 0.0, accuracy: 0.01)
    }

    func testCalculateTotal_withZeroTaxRate() {
        let items = [Item(name: "A", price: 25.0)]
        let total = calculator.calculateTotal(items: items, taxRate: 0.0)
        XCTAssertEqual(total, 25.0, accuracy: 0.01)
    }
}

Best Practices

Always review generated tests. AI-generated tests are a starting point. Verify they test meaningful behavior, not just implementation details. Check that assertions are correct and edge cases are realistic.
Good tests verify what your code does, not how it does it. If Parsaa generates a test that relies on internal implementation details, refactor it to test the public interface instead.
Double-check that expected values in assertions are correct. AI can miscalculate expected outputs, especially for complex logic.
Parsaa covers common edge cases, but you know your domain best. Add tests for scenarios specific to your business logic.
Each test should be independent. If Parsaa generates tests that share mutable state, refactor them to use fresh setup in each test method.
Use test generation as a starting point, then iterate. Generated tests get you to 70-80% coverage quickly — you fill in the domain-specific gaps.