Back to Skills

platform-apex-test-run

Apex test execution, coverage analysis, and test-fix loops with 120-point scoring. Use when the user needs to run Apex tests, check code coverage, fix failing tests, or work with *Test.cls / *_Test.cls files. TRIGGER when: user runs Apex tests, checks code coverage, fixes failing tests, or touches *Test.cls / *_Test.cls files. DO NOT TRIGGER when: writing Apex production code (use platform-apex-generate), Agentforce agent testing (use agentforce-test), or Jest/LWC tests (use experience-lwc-gener

721stars262forksUpdated 7/17/2026

Security Assessment

Safe(100/100)
Security Score100/100

About platform-apex-test-run

platform-apex-test-run handles Salesforce Apex test execution, coverage analysis, and disciplined test-fix loops, with a 120-point scoring guide for judging test confidence. It solves the problem of running Apex tests, checking code coverage, interpreting failures, improving coverage, and managing structured fix loops for Salesforce code. It owns tasks involving sf apex run test workflows, Apex unit-test failures, coverage analysis, identifying uncovered lines and missing scenarios, and structured test-fix loops, while delegating production code work, Agentforce agent testing, and LWC/Jest testing to other skills.

The recommended workflow gathers context first (target org alias, test scope, coverage threshold, diagnosis-only vs. fix loop, existing data factories), then discovers test scope, runs the smallest useful test set first, analyzes results (failing methods, exception types and stack traces, uncovered lines), runs a disciplined fix loop, and improves coverage intentionally across positive, negative, bulk (251+ records), and callout/async paths. It ships high-signal rules such as defaulting to SeeAllData=false, requiring meaningful assertions, testing bulk behavior with 251+ records to cross the 200-record trigger batch boundary, using @TestSetup, and pairing Test.startTest() with Test.stopTest() for async. A rich set of reference files and asset templates is included — for example references/cli-commands.md, references/mocking-patterns.md, assets/basic-test.cls, assets/bulk-test.cls, assets/dml-mock.cls, and scripts/parse-test-results.py, a post-tool hook that parses sf apex run test JSON output for the auto-fix loop.

Target users are Salesforce developers running Apex tests, checking coverage, or fixing failing tests, especially when touching *Test.cls / *_Test.cls files. It documents common gotchas (tests passing locally but failing in CI, coverage drops after refactor, uncommitted-work callout errors, mocks not taking effect, @TestSetup data requiring re-query) and a fixed output format reporting tests run, pass/fail, coverage, root-cause findings, and next steps. Its Score Guide interprets results, with 108+ indicating strong production-grade confidence and below 84 meaning below standard.

FAQ

When should I use this skill versus another Apex skill?

Use platform-apex-test-run for running tests, checking coverage, interpreting failures, and structured test-fix loops. Delegate writing or refactoring production Apex to platform-apex-generate, Agentforce agent testing to agentforce-test, and LWC/Jest testing to experience-lwc-generate.

Why test with 251+ records?

Bulk behavior should be tested with 251+ records because triggers process in batches of 200, so 251 records crosses the batch boundary and exercises true bulk behavior.

What context does the skill gather before running tests?

It asks for or infers the target org alias, the desired test scope (single class, specific methods, suite, or local tests), the coverage threshold expectation, whether you want diagnosis only or a test-fix loop, and whether related test data factories already exist.

What does the score guide mean?

It uses a 120-point scoring scale: 108+ indicates strong production-grade test confidence, 96–107 is a good suite with minor gaps, 84–95 is acceptable but needs stronger coverage/assertions, and below 84 is below standard and should be revised before relying on it.

How does the auto-fix loop consume test results?

The scripts/parse-test-results.py post-tool hook parses the JSON output of sf apex run test and formats failures for the auto-fix loop.

All Files

15 files
assets/basic-test.cls7.4 KB
View
assets/dml-mock.cls10.1 KB
View
assets/test-data-factory.cls12.0 KB
View
references/mocking-patterns.md13.2 KB
View
references/test-patterns.md4.2 KB
View
assets/bulk-test.cls9.3 KB
View
assets/stub-provider-example.cls10.8 KB
View
references/cli-commands.md5.7 KB
View
references/test-fix-loop.md2.0 KB
View
scripts/parse-test-results.py12.7 KB
View
assets/mock-callout-test.cls11.9 KB
View
README.md3.0 KB
View
references/performance-optimization.md7.5 KB
View
references/testing-best-practices.md14.2 KB
View
SKILL.md6.8 KB
View

Install platform-apex-test-run

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill