Credits:
The code below has been adapted from the cookbook recipe http://developer.force.com/cookbook/recipe/automated-unit-test-execution. Re-posting this since the link appears to be broken.
STEP 1:
STEP 2:
Create the apex classes below.
STEP 3:
Schedule the apex class 'AutomatedTestJobQueuer'. This will run the apex tests.
STEP 4:
Schedule the apex class 'AutomatedTestingJob'. This will send the email. Make sure you have enough gap between these two jobs to allow all tests to run. Sample here is one hour, you might want to increase this if you have many apex tests.
The code below has been adapted from the cookbook recipe http://developer.force.com/cookbook/recipe/automated-unit-test-execution. Re-posting this since the link appears to be broken.
STEP 1:
- Create an object with API name AutomatedTestingQueue__c
- Create a field on this object of type TEST(40) with API name AsyncId__c
STEP 2:
Create the apex classes below.
- Modify the SOQL query to pick test classes to execute. The query in this sample just picks any class with the name TEST in it.
- Also update your email address to receive the results.
STEP 3:
Schedule the apex class 'AutomatedTestJobQueuer'. This will run the apex tests.
STEP 4:
Schedule the apex class 'AutomatedTestingJob'. This will send the email. Make sure you have enough gap between these two jobs to allow all tests to run. Sample here is one hour, you might want to increase this if you have many apex tests.