
Description
Generating Apex Tests is an agent skill for writing production-ready Apex test classes and running disciplined test-fix loops with coverage analysis. Its core principles set the standard the agent works to. Each test method checks one scenario, and positive, negative and bulk tests are kept apart. Related but distinct inputs, such as null and empty, get separate test methods. Tests are bulkified with 251 or more records to cross the 200-record trigger batch boundary, and batch Apex tests set batchSize at or above the test record count, since only one execute call runs in test context. Test data is created through a TestDataFactory class, never inline in @TestSetup, and the skill rules out reliance on org data or hardcoded IDs. Assertions use exact expected values and failure messages, through the Assert class only, not the legacy System.assert methods. External boundaries are mocked: HttpCalloutMock for callouts, Test.setFixedSearchResults for SOSL, and DML mock classes for database isolation, with constructor injection for testability. Negative paths are tested too. Test.startTest and Test.stopTest are paired to reset governor limits and force async work. The skill has reference files on async testing, test data factories, assertion patterns and mocking patterns. It is for Salesforce developers writing or repairing Apex tests.…
Highlights
- One behavior per test method, with negative and bulk tests
- Bulk tests at 251 or more records
- TestDataFactory-based setup, no hardcoded IDs
- Assert class and HttpCalloutMock mocking patterns
Ratings & Reviews
No ratings yet
Be the first to rate generating-apex-test.
People also visit

generating-apex
Primary Apex authoring skill for class generation, refactoring, and review
generating-apex-test FAQ
What does the skill produce?
Apex test classes and a test-fix loop with coverage analysis, following the skill's rules on bulk data, mocking and assertions.
Why 251 records?
The skill says to test with 251 or more records to cross the 200-record trigger batch boundary.
How do I install it?
Run npx skills add https://github.com/forcedotcom/sf-skills --skill generating-apex-test in your project.
Is it free and open source?
Yes. It is published in the public forcedotcom/sf-skills repository on GitHub.
What do the security audits say?
skills.sh lists Gen Agent Trust Hub: Pass, Socket: Pass and Snyk: Pass for this skill.
What are the best generating-apex-test alternatives?
Popular alternatives to generating-apex-test include platform-apex-test-generate, running-apex-tests and platform-apex-test-run. See all generating-apex-test alternatives




