generating-apex-test

安装量: 1.6K
排名: #4723

安装

npx skills add https://github.com/forcedotcom/sf-skills --skill generating-apex-test

Generating Apex Tests Generate production-ready Apex test classes and run disciplined test-fix loops with coverage analysis. Core Principles One behavior per method — each test method validates a single scenario. Separate positive, negative, and bulk tests. NEVER combine related-but-distinct inputs (e.g., null and empty) in one method — create NullInput and EmptyInput as separate test methods Bulkify tests — test with 251+ records to cross the 200-record trigger batch boundary. Batch Apex exception: in test context only one execute() invocation runs, so set batchSize >= testRecordCount . See references/async-testing.md Isolate test data — every @TestSetup must delegate record creation to a TestDataFactory class. If none exists, create one first. Never build record lists inline in @TestSetup . Never rely on org data ( SeeAllData=false ) or hardcoded IDs. For duplicate rule handling, see references/test-data-factory.md Assert meaningfully — use exact expected values computed from test data setup. NEVER use range assertions or approximate counts when the value is deterministic. Always include failure messages. See references/assertion-patterns.md Use Assert class only — Assert.areEqual , Assert.isTrue , Assert.fail , etc. Never use legacy System.assert , System.assertEquals , or System.assertNotEquals Mock external boundaries — use HttpCalloutMock for callouts, Test.setFixedSearchResults for SOSL, DML mock classes for database isolation. Design for testability via constructor injection. See references/mocking-patterns.md Test negative paths — validate error handling and exception scenarios, not just happy paths Wrap with start/stop — pair Test.startTest() with Test.stopTest() to reset governor limits and force async execution Test.startTest() / Test.stopTest() Always wrap the code under test in Test.startTest() / Test.stopTest() : Show more Installs 1.6K Repository forcedotcom/sf-skills GitHub Stars 553 First Seen May 13, 2026 Security Audits Gen Agent Trust Hub Pass Socket Pass Snyk Pass

返回排行榜