-- Setup to run via scheduled process
-- Test results are store in objects
- - `Test_Run__c`: A test Job instance
- - `Test_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
+- Setup to run via scheduled process
+- Test results are stored in objects
+ - `Test_Run__c`: A test job instance
+ - `Test_Run_Method_Result__c`: An individual test method result
+- Tracks "First Failure" to help with debugging / noise reduction
+- Automatically 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
## Install
@@ -19,8 +18,14 @@ A Salesforce package to help monitor organization's unit tests health.
## Setup
+### Permission set
+
+Assign the **Test Runner** permission set (`Test_Runner`) to users who need the UI (tabs, list views, field-level security). Missing FLS does not break scheduled Apex—the schedulers run as the user who scheduled them.
+
### Scheduling
+Schedule **TestRunScheduler** and **TestRunProcessor** as a user who can query Apex tests (typically someone with **Author Apex** or **System Administrator**).
+
1. Schedule the unit test run frequency (example below runs daily at 3am):
```java
@@ -39,42 +44,75 @@ System.Schedule('Test Processor', sch, testProcessor);
**NOTES:**
-- If you find your test runs are failing inconsistently, you may need to [disabling "parallel" test runs](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_best_practices.htm)
+- If you find your test runs are failing inconsistently, you may need to [disable "parallel" test runs](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_best_practices.htm).
+- Cleanup is automatic: **TestRunScheduler** enqueues **TestRunCleanup**, which prunes processed runs after 30 days and abandons unprocessed runs after 2 days.
### Sending Notifications

-To keep things as flexible & upgradable possible, we've decided not to package any notification logic with the "unlocked" package.
+To keep things as flexible and upgradable as 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.
+Since the results are stored in an object, you can use a tool of choice to receive notifications about failures.
-However, we have included a simple workflow to send an email when a test fails.
+We include optional notification metadata (email template, Visualforce component, email alert, and a record-triggered Flow) under `notifications/workflow-email`. The Flow ships **inactive** (`Draft`) so you can configure recipients before it sends mail.
-**To install workflow email alert:**
+**To deploy notification metadata:**
-- 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
+```bash
+sf project deploy start --source-dir notifications/workflow-email --target-org