Testing isn't just Apex tests. A comprehensive strategy:
1. Unit tests (Apex):
- Per class, per method.
- 75% coverage minimum, 85%+ target.
- Bulk tests (200 records).
- Mock dependencies.
- Negative cases (validation, permissions).
2. LWC unit tests (Jest):
- Per component.
- Test public API, not implementation.
- Mock Apex methods, LDS, LMS.
- Async resolution patterns.
3. Integration tests:
- End-to-end across systems.
- Test data prep + teardown.
- Mock external services in test env.
4. UI tests (Cypress / Playwright):
- User journeys.
- Visual regression where useful.
- Run against UAT sandbox.
5. Performance tests:
- Load test under expected concurrent users.
- Page render times under data volume.
- Bulk operation timing.
6. Security tests:
- Penetration testing.
- OWASP checks.
- Permission audits.
7. UAT:
- Business user testing.
- Real scenarios.
- Sign-off gate.
8. Production monitoring:
- Synthetic transactions periodically.
- Error rate monitoring.
- Real-user monitoring.
Test tooling stack:
- Apex unit tests (built-in).
- Jest for LWC.
- PMD / ESLint for static analysis.
- Cypress / Playwright for UI.
- Provar / Tosca for end-to-end (some orgs).
- Custom test data factories.
Quality gates in CI/CD:
- Tests pass.
- Coverage threshold met.
- PMD findings under threshold.
- ESLint clean.
Architect role: define testing standards, set quality gates, mentor team on test design.
Common gap: tests for Flows and declarative automation. Salesforce has limited tools; manual UAT often required.
The senior insight: untested code is broken code waiting to fail. Testing investment compounds.
