ApexIntermediatetestingtriggersbulkification
Test trigger bulk paths with meaningful assertions not assert(true)
Real World Scenario
Account trigger tests insert one record with System.assert(true). Production bulk import fails with undeclared SOQL in loop.
Expected Answer
• Minimum 200 records in trigger test data via Test.loadData or loop insert
• Assert record counts, field values, and related record creation
• Test update and delete contexts not only insert
• Negative test: null lookup, validation failure, recursion guard activation
• HttpCalloutMock for triggers enqueueing async callout jobs
• Test.startTest/stopTest for async job execution in same test
• CI fails PR if trigger class lacks bulk test method
Follow-Up Questions & Answers
Click to expand — each follow-up includes a direct, interview-ready answer
Main difference: use case and scale. Minimum 200 records in trigger test data via Test.loadData or loop insert. Assert record counts, field values, and related record creation. Pick based on your integration pattern and team capability. Single-record trigger tests are false confidence—bulk test is definition of done for triggers. Balance speed of delivery with maintainability.
Architect Perspective
Single-record trigger tests are false confidence—bulk test is definition of done for triggers.