forcedotcom/sf-skills / plugins/builder/salesforce-development/skills/platform-apex-test-run
platform-apex-test-run
VerifiedApex test execution, coverage analysis, and test-fix loops with 120-point scoring. Use when the 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-generate).
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 3.0 KB |
| SKILL.md | skill md | 7.3 KB |
| assets/basic-test.cls | other | 12.7 KB |
| assets/bulk-test.cls | other | 11.3 KB |
| assets/dml-mock.cls | other | 12.6 KB |
| assets/mock-callout-test.cls | other | 13.6 KB |
| assets/stub-provider-example.cls | other | 12.2 KB |
| assets/test-data-factory.cls | other | 14.3 KB |
| references/cli-commands.md | markdown | 5.7 KB |
| references/mocking-patterns.md | markdown | 13.2 KB |
| references/performance-optimization.md | markdown | 7.5 KB |
| references/test-fix-loop.md | markdown | 2.0 KB |
| references/test-patterns.md | markdown | 4.2 KB |
| references/testing-best-practices.md | markdown | 15.6 KB |
| scripts/parse-test-results.py | script | 12.8 KB |
README.md
View on GitHub# platform-apex-test-run
Comprehensive Salesforce testing skill with test execution, code coverage analysis, and agentic test-fix loops. Run tests, analyze coverage, and automatically fix failing tests.
## Features
- **Test Execution**: Run Apex tests via sf CLI with coverage analysis
- **Coverage Analysis**: Parse reports, identify untested code paths
- **Failure Analysis**: Parse failures, identify root causes, suggest fixes
- **Agentic Test-Fix Loop**: Automatically fix failing tests and re-run
- **120-Point Scoring**: Validation across 6 categories
- **Bulk Testing**: Validate with 251+ records for governor limits
## Quick Start
### 1. Invoke the skill
```yaml
Skill: platform-apex-test-run
Request: "Run all tests and show coverage report for org dev"
```
### 2. Common operations
| Operation | Example Request |
|-----------|-----------------|
| Run class | "Run AccountServiceTest in org dev" |
| Run all | "Run all local tests with coverage" |
| Coverage report | "Show code coverage for AccountService" |
| Fix loop | "Run tests and fix failures automatically" |
| Generate tests | "Create tests for AccountService class" |
## Key Commands
```bash
# Run single test class
sf apex run test --class-names MyClassTest --code-coverage --result-format json --target-org [alias]
# Run all local tests
sf apex run test --test-level RunLocalTests --code-coverage --result-format json --target-org [alias]
# Run specific methods
sf apex run test --tests MyClassTest.testMethod1 --target-org [alias]
# Run with output directory
sf apex run test --class-names MyClassTest --output-dir test-results --target-org [alias]
```
## Scoring System (120 Points)
| Category | Points | Focus |
|----------|--------|-------|
| Coverage | 25 | Overall and per-class coverage |
| Assertions | 25 | Meaningful assertions, edge cases |
| Bulk Testing | 20 | 251+ records, governor limits |
| Data Isolation | 20 | @TestSetup, test data factories |
| Negative Tests | 15 | Error paths, exceptions |
| Documentation | 15 | Test descriptions, clear naming |
## Test Thresholds
| Level | Coverage | Purpose |
|-------|----------|---------|
| Production | 75% minimum | Required for deployment |
| Recommended | 90%+ | Best practice target |
| Critical paths | 100% | Business-critical code |
## Cross-Skill Integration
| Related Skill | When to Use |
|---------------|-------------|
| sf-apex | Fix failing Apex code |
| platform-apex-logs-debug | Analyze test failures with debug logs |
| platform-data-manage | Generate 251+ bulk test records |
| platform-metadata-deploy | Validate before deployment |
## Agentic Test-Fix Loop
When enabled, the skill will:
1. Run tests and capture failures
2. Analyze error messages and stack traces
3. Generate fixes for common issues
4. Apply fixes and re-run tests
5. Repeat until all tests pass or max iterations reached
## Documentation
- [Testing Best Practices](references/testing-best-practices.md)
## Requirements
- sf CLI v2
- Target Salesforce org
- Test classes in org or local project
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |