-
Notifications
You must be signed in to change notification settings - Fork 5
Testing Guidance
Patrick Gidich edited this page Mar 19, 2019
·
5 revisions
Unit Tests and Apex Tests: Scratch Orgs QA Feature Tests and Regression Tests: Dev-Pro Sandbox Staging and user-acceptance testing: Partial-Full sandbox
- Create Developer Environments
- Develop using web and local tools
- Migrate changes to integration environment
- Test
- Migrate changes to UAT environment
- Perform user-acceptance testing
- Migrate changes to staging environment
- Replicate production changes in staging environment
- Schedule the release
- Authorize Dev Hub
- Create Scratch Org
- Install package / push source
- Run Tests
- Delete Org
- Create / Send Report
- 75% of Apex statements must be executed (strive for 100% code coverage)
- All Apex triggers must be called.
- All Apex tests must execute without throwing any uncaught exceptions or exceeding governors.
Best Practices:
- Arrange the data correctly, act on it, and assert to make sure your code is doing what it should be doing
- Run tests as real user profiles ○ Sfdx force:user:create
- Exercise bulk trigger functionality ○ Can be called with more than one object-- aim for 10-20. ○ Aim to make sure it 'works' - not to test limits
- Plan ahead Refresh your sandbox when it makes sense for the project
- Build in Assert methods into your test ○ System.Assert(expect, actual, 'friendly message') Helps you find what went wrong in test failure
- Use Test.startTest and Test.stopTest commands. Gives you a new set of governor limits, and runs any asynchronous code
- Write Positive Tests
- Write Negative Tests
- User tests ○ Create a user with a given profile, and assign permissions to them
- turn off seeAllData. This ensures you don't get random failures if data changes
- Do not install LTS in a production org. Lightning tests don’t run in an isolated testing context, and DML operations you perform in a test are not rolled back when the test completes.
- Bob the Builder just developed an feature and he sends it to the develop branch. QA tester, Oscar, pulls into his environment, and runs the script that creates a scratch org, and runs the apex tests. Next, he pushes the application to the Partial Copy Sandbox, and runs his regression and features tests in the sandbox. When Oscar feels like the application passed all his tests, he then pushes to the Full sandbox for UAT testing.
- Tester Megan Goes into the Full Sandbox, and goes about UAT testing. She spins up some user accounts, and works on using the application. When she feels like the application passes her user tests, she sends it off to the production org. This happens after the packages have been updated and installed.
- Carl, QA tester, is testing the application when the apex code coverage reaches 70%. The application cannot be passed further, so he lets the developer know, and deletes his scratch org.
-- Valerie Belova
- Introduction
- Quality Hooks
- Approvals
- Promotion Automation
SFDX Package Development
Developer Machine Setup
Extras