Loading...
Loading...
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 generating-apex), Agentforce agent testing (use testing-agentforce), or Jest/LWC tests (use generating-lwc-components).
npx skill4agent add forcedotcom/afv-library running-apex-testsrunning-apex-testssf apex run testgenerating-apextesting-agentforcegenerating-apex| Rule | Rationale |
|---|---|
Default to | Ensures test isolation; prevents reliance on org-specific data |
| Every test must assert meaningful outcomes | Tests with no assertions prove nothing and give false confidence |
| Test bulk behavior with 251+ records | Triggers process in batches of 200; 251 records crosses the boundary |
Use factories / | Consistent data creation in one place; rolled back between test methods |
Pair | Ensures async operations (queueable, future) complete before assertions |
| Do not hide flaky org dependencies inside tests | Prevents intermittent failures tied to org state |
| Issue | Resolution |
|---|---|
| Test passes locally but fails in CI org | Check for |
| Coverage drops unexpectedly after refactor | Run focused class-level tests first, then widen to |
| "Uncommitted work pending" error in callout test | DML and HTTP callouts cannot be mixed in the same test context without |
| Mock not taking effect in test | Ensure |
| |
Test run: <scope>
Org: <alias>
Result: <passed / partial / failed>
Coverage: <percent / key classes>
Issues: <highest-signal failures>
Next step: <fix class, add test, rerun scope, or widen regression>| Need | Delegate to | Reason |
|---|---|---|
| Fix production code or author test classes | | Code generation and repair |
| Create bulk / edge-case test data | handling-sf-data | Realistic test datasets |
| Deploy updated tests to org | deploying-metadata | Deployment workflows |
| Inspect detailed runtime logs | debugging-apex-logs | Deeper failure analysis |
| File | When to read |
|---|---|
| All |
| Test class templates — basic, bulk (251+), mock callout, and data factory patterns |
| Core testing principles — AAA pattern, naming conventions, bulk, negative, and mock strategies |
| Agentic test-fix loop implementation and failure analysis decision tree |
| HttpCalloutMock, DML mocking, StubProvider, and selector mocking patterns |
| Techniques to reduce test execution time — DML mocking, SOQL mocking, loop optimizations |
| Template: standard test class with |
| Template: bulk test with 251+ records that crosses the 200-record trigger batch boundary |
| Template: HTTP callout mock using |
| Template: reusable |
| Template: |
| Template: |
| Post-tool hook — parses |
| Score | Meaning |
|---|---|
| 108+ | strong production-grade test confidence |
| 96–107 | good test suite with minor gaps |
| 84–95 | acceptable but strengthen coverage / assertions |
| < 84 | below standard; revise before relying on it |