-
-
Notifications
You must be signed in to change notification settings - Fork 206
Description
Feature Description
After running tests with test_sim, test_device, or test_macos, there is no way to see what code is covered. This makes it hard to generate useful tests automatically.
Xcode already provides xcrun xccov to read coverage data from .xcresult bundles, but it is not exposed.
I would like to propose two simple read-only tools: one to show overall coverage, and one to show uncovered lines for a file.
Both would use an .xcresult bundle and would not change any existing tools.
I am interested to submit a PR if this fits the project direction.
Use Cases
- The agent runs tests, checks coverage, and then writes tests only for uncovered code instead of guessing.
- After running
test_sim, the agent shows overall coverage and highlights weak areas. - A developer asks to improve coverage for a specific file, and the agent checks which functions are not tested and writes tests for them.
- In CI/CD, tests run first, then coverage is checked to make sure it meets a minimum requirement before continuing.
Example Interactions
User: Run the tests for my app and tell me what's not covered
AI: I'll run the tests first and then check coverage.
[calls test_sim with -enableCodeCoverage YES and -resultBundlePath]
Tests completed: 47 passed, 2 failed, 1 skipped.
Now let me check coverage...
[calls get_coverage_report]
Overall coverage: 62.3%
Lowest coverage files:
- CartManager.swift: 45.2%
- PaymentGateway.swift: 32.1%
Want me to write tests for the uncovered code in these files?
User: Yes, start with CartManager.swift
AI: Let me see exactly what's untested.
[calls get_uncovered_lines for CartManager.swift]
Uncovered functions:
- removeAll() at line 41 (0/6 lines)
- applyDiscount(_:) at line 67 (0/12 lines)
I'll write tests for removeAll() and applyDiscount() now.