You need to sign in to do that
Don't have an account?
Lori Buchowicz
System.AsyncException: Based on configured schedule, the given trigger 'SCHEDULED_APEX_JOB_TYPE.000000000000000' will never fire.
Schedule returning error message - assistance needed please:
*/
@isTest
public class NightlyDepositBatchTest {
public static String CRON_EXP = '0 0 0 15 3 ? 2022';
@testSetup
static void setup() {
List donations = new List();
for (Integer i=0;i donList = [SELECT Id, Donation_Use__c, Tributee__c, Gift_Type__c, Amount__c, GL_Code__c FROM Donations__c];
for(Donations__c donation: donList){
Test.setCreatedDate(donation.id, Datetime.newInstance(date.today(), Time.newInstance(0,0,0,0)).addDays(-1));
}
update donList;
}
@isTest static void test() {
Test.startTest();
NightlyDepositBatch uca = new NightlyDepositBatch(Date.today());
Id batchId = Database.executeBatch(uca);
Test.stopTest();
// after the testing stops, assert records were created properly
List depositLines = [SELECT Id,SUM(Amount__c) FROM QB_Deposit_Line__c GROUP BY Id LIMIT 1];
System.assertEquals(100, (Decimal)depositLines[0].get('expr0'));
}
@isTest static void test2() {
Test.startTest();
String jobId = System.schedule('ScheduledApexTest',
CRON_EXP,
new NightlyDepositSchedule());
Test.stopTest();
}
}
Unit test now returning error when deploying new test cases for other development being done and this test case not firing the scheduled test job. I have been searching for how to fix the test case and am not finding how to best resolve in the sandbox to update this and get any coverage listed for the Nightly Batch Schedule job in production.
With this above issue not able to get code coverage on this job -
global class NightlyDepositSchedule implements Schedulable{
global void execute(SchedulableContext sc) {
NightlyDepositBatch n1 = new NightlyDepositBatch(Date.today());
ID batchprocessid = Database.executeBatch(n1,Test.isRunningTest() ? 3 : 1);
}
}
*/
@isTest
public class NightlyDepositBatchTest {
public static String CRON_EXP = '0 0 0 15 3 ? 2022';
@testSetup
static void setup() {
List donations = new List();
for (Integer i=0;i donList = [SELECT Id, Donation_Use__c, Tributee__c, Gift_Type__c, Amount__c, GL_Code__c FROM Donations__c];
for(Donations__c donation: donList){
Test.setCreatedDate(donation.id, Datetime.newInstance(date.today(), Time.newInstance(0,0,0,0)).addDays(-1));
}
update donList;
}
@isTest static void test() {
Test.startTest();
NightlyDepositBatch uca = new NightlyDepositBatch(Date.today());
Id batchId = Database.executeBatch(uca);
Test.stopTest();
// after the testing stops, assert records were created properly
List depositLines = [SELECT Id,SUM(Amount__c) FROM QB_Deposit_Line__c GROUP BY Id LIMIT 1];
System.assertEquals(100, (Decimal)depositLines[0].get('expr0'));
}
@isTest static void test2() {
Test.startTest();
String jobId = System.schedule('ScheduledApexTest',
CRON_EXP,
new NightlyDepositSchedule());
Test.stopTest();
}
}
Unit test now returning error when deploying new test cases for other development being done and this test case not firing the scheduled test job. I have been searching for how to fix the test case and am not finding how to best resolve in the sandbox to update this and get any coverage listed for the Nightly Batch Schedule job in production.
With this above issue not able to get code coverage on this job -
global class NightlyDepositSchedule implements Schedulable{
global void execute(SchedulableContext sc) {
NightlyDepositBatch n1 = new NightlyDepositBatch(Date.today());
ID batchprocessid = Database.executeBatch(n1,Test.isRunningTest() ? 3 : 1);
}
}
It is not firing because the CRON_EXP = '0 0 0 15 3 ? 2022' is in the past. You need to put in the future so it can run for a long time.
Here is the screen shot with the highlighted part I fixed. The shared code has too many missing curly brackets and some code issues, which I have fixed and shared below.
Here is fixed code.
I hope this help.
Please don't forget to mark it a best answer.
All Answers
It is not firing because the CRON_EXP = '0 0 0 15 3 ? 2022' is in the past. You need to put in the future so it can run for a long time.
Here is the screen shot with the highlighted part I fixed. The shared code has too many missing curly brackets and some code issues, which I have fixed and shared below.
Here is fixed code.
I hope this help.
Please don't forget to mark it a best answer.