A Salesforce package to help monitor organization's unit tests health.
- Setup to run via scheduled process
- Test results are store in objects
Test_Run__c
: A test Job instanceTest_Run_Method_Result__c
: An individual test method result- Results are pruned after 30 days
- Tracks "First Failure" to help with debugging / noise reduction
- Automaticly builds Audit Log query to help troubleshoot what changes might have caused a test to fail
- Captures Run Time, which can help identify performance issues or slow tests
- Schedule the unit test run frequency (example below runs daily at 3am):
TestRunScheduler testRunner = new TestRunScheduler();
String sch = '0 0 3 * * ?'; // schedule interval time
System.Schedule('Test Runner', sch, testRunner);
- Schedule the processor to check for finished test runs hourly (or more often if you want):
TestRunProcessor testProcessor = new TestRunProcessor();
String sch = '0 15 * * * ?'; // schedule interval time
System.Schedule('Test Processor', sch, testProcessor);
NOTES:
- If you find your test runs are failing inconsistently, you may need to disabling "parallel" test runs
To keep things as flexible & upgradable possible, we've decided not to package any notification logic with the "unlocked" package.
Since the results are stored in an object, you can you use tool of choice to receive notifications about failures.
However, we have included a simple workflow to send an email when a test fails.
To install workflow email alert:
- run
sfdx force:source:convert -r notifications/workflow-email -d ./dist/workflow-email
to create a metadata package - run
sfdx force:mdapi:deploy -d ./dist/workflow-email/ -w -1
to deploy - Update Workflow Action "Test Run Failure Notification Alert", to include your email addresses
We may add more prebuilt notification methods in the future.
TIP: If you only want to be notified of new failures, update the workflow to send if Test_Run__r.New_Failures__c > 0
Make your updates, release a new version:
- open
sfdx-project.json
- increment
versionName
andversionNumber
respectively - save
- increment
sfdx force:package:version:create -p TestRunner -d force-app -x --wait 10 -v CCC-SFDC-Production
Once you are ready to release the updated package, use the 04t* Id from the new release to promote:
sfdx force:package:version:promote -p 04t\*
- update
README.mdd
install step with the new install URL