platform-apex-test-generate

Generate and validate Salesforce Apex test classes with TestDataFactory patterns, mocking, and coverage analysis.

Updated Jul 2, 2026
One-click install
npx skills add https://github.com/padjei/SF_Build --skill platform-apex-test-generate-padjei
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: platform-apex-test-generate
Source: https://github.com/padjei/SF_Build/tree/main/.claude/skills/platform-apex-test-generate
Command: npx skills add https://github.com/padjei/SF_Build --skill platform-apex-test-generate-padjei

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve? Writing reliable Apex test classes is time-consuming and error-prone: developers must handle bulk data setup, governor limits, async execution, callout mocking, and coverage thresholds while avoiding brittle assertions. This Skill automates the creation of production-ready Apex test classes and runs disciplined test-fix loops until tests pass and coverage targets are met. ## Core Features & Use Cases - Test Class Generation: Creates {ClassName}Test.cls plus its .cls-meta.xml file using Given/When/Then structure, Assert class assertions, and TestDataFactory-based @TestSetup methods. - Bulk and Async Testing: Enforces 251+ record bulk tests, correct batch sizing, and proper Test.startTest()/Test.stopTest() wrapping for batch, queueable, future, and scheduled jobs. - Mocking Strategies: Provides HttpCalloutMock, SOSL fixed search results, DML injection, and System.StubProvider patterns for isolating external boundaries. - Test-Fix Loop: Runs sf apex run test commands, analyzes failures and coverage, and iterates fixes (max 3 iterations) with delegation of production code issues. - Use Case: After writing a new Apex service class, ask the AI to generate its test class — it produces the test file, metadata file, a TestDataFactory if missing, runs the tests against your org, and fixes failures until 90%+ coverage is reached. ## Quick Start Generate an Apex test class with full coverage for MyService.cls and run it against my dev org.

Frequently Asked Questions about platform-apex-test-generate

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

FAQPage Schema
How do I generate an Apex test class for a Salesforce service class?▼

Provide the target production class and the Skill generates a test class using Given/When/Then structure, a TestDataFactory for @TestSetup data, and Assert-class assertions. It creates both the .cls file and its .cls-meta.xml metadata file, then runs the tests via sf apex run test.

How to mock HTTP callouts in Apex tests?▼

Implement the HttpCalloutMock interface with a respond() method returning a configured HttpResponse, then register it with Test.setMock() before Test.startTest(). For multiple endpoints, use a multi-request mock keyed by endpoint, or StaticResourceCalloutMock for large JSON payloads.

Why does my batch Apex test only process some records?▼

In test context only one execute() invocation runs, so the batch size must be greater than or equal to your test record count. Call Database.executeBatch(batch, 200) with 200 or fewer records, otherwise only the first batch-size chunk is processed.

What code coverage is required to deploy Apex to production?▼

Salesforce requires a minimum of 75% org-wide coverage for production deployment. This Skill targets 90%+ as a best practice and 100% for business-critical paths, covering positive, negative, bulk, and callout/async scenarios.

Can this Skill test Lightning Web Components or Jest tests?▼

No, it is scoped to server-side Apex tests only and explicitly does not trigger for Jest/LWC tests. It also delegates production Apex code changes to the separate platform-apex-generate skill rather than modifying business logic itself.