running-apex-tests

Execute Salesforce Apex unit tests with coverage analysis and failure diagnosis.

803|289|Updated Nov 7, 2025
One-click install
npx skills add https://github.com/forcedotcom/sf-skills --skill running-apex-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: running-apex-tests
Source: https://github.com/forcedotcom/sf-skills/tree/main/skills/running-apex-tests
Command: npx skills add https://github.com/forcedotcom/sf-skills --skill running-apex-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you execute Salesforce Apex unit tests, diagnose failing tests with actionable root-cause guidance, and improve code coverage through an agentic test-fix loop.

Core Features & Use Cases

  • Apex test execution & coverage analysis: Run single classes or broader suites with coverage metrics, then interpret which lines/classes are under-covered.
  • Failure analysis for faster debugging: Parse failures into error type, affected test method/class, stack trace context, and recommended next actions.
  • Agentic test-fix loop: Iteratively propose fixes (delegating code changes to sf-apex) and rerun until tests pass or the iteration limit is reached.
  • Best-practice scoring & validation: Apply a structured 120-point rubric across coverage, assertions, bulk testing, isolation, negative tests, and documentation quality.

Quick Start

Tell the agent: Run Apex tests in my org dev, show the coverage report, and fix any failing tests automatically.

Frequently Asked Questions about running-apex-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run Salesforce Apex unit tests and analyze code coverage?

Run Salesforce Apex unit tests with coverage analysis to interpret which lines and classes are under-covered. Execution provides coverage metrics for single classes or broader suites, identifying uncovered code paths.

Why do my Apex tests fail and how can I diagnose the root cause?

Apex test failures are diagnosed by parsing the error type, affected test method, and stack trace context. This provides actionable root-cause guidance and recommended next actions to resolve the issue.

Can I automatically fix failing Apex tests and rerun them?

Automatically fix failing Apex tests using an agentic test-fix loop. It iteratively proposes fixes and reruns the tests until they pass or the iteration limit is reached.

What is the best way to validate Apex test quality against best practices?

Validate Apex test quality using a structured 120-point rubric. This scores tests across coverage, assertions, bulk testing, isolation, negative tests, and documentation to ensure comprehensive validation.

Does the Apex test-fix loop work with the sf cli for local test suites?

The test-fix loop supports deterministic sf apex run test workflows for local and regression test suites. It provides structured output requirements to iteratively resolve failures.

What should I do when Apex tests hit governor limits during execution?

When Apex tests hit governor limits, use failure analysis to identify the specific limit breach within the stack trace. The diagnosis recommends next actions to optimize the test or code structure.