You need to sign in to do that
Don't have an account?
linda b
53% test coverage by not including for loop
Hello, I have this Apex class:
and i am missing coverage for the creation of the case object, this is what I have so far, but i am still only at 53% for some reason:
@isTest private class CaseGenerator_Test{ static testmethod void testSchduler() { Contract__c ctr = new Contract__c(); ctr.Jamba_Company__c = '0010Y00001YriCE'; ctr.Price_per_job_posting__c = 800.00; if(ctr.Invoice_Type__c != null){ ctr.Invoice_Type__c = 'Per Unit'; } insert ctr; Billing_Unit__c billingUnit = new Billing_Unit__c(); billingUnit.Contract__c = ctr.Id; billingUnit.Invoicing_Date__c = Date.today(); billingUnit.Name = 'Test BU1'; insert billingUnit; Case cse = new Case( subject='Rechnung erstellen: '+billingUnit.Name, Contract__c=billingUnit.Contract__c, Automatically_generated__c=TRUE, Billing_Unit__c=billingUnit.Id, Status='New'); insert cse; String CRON_EXP = '0 0 0 15 3 ? *'; Test.startTest(); String jobId = System.schedule('CaseGenerator', CRON_EXP, new CaseGenerator()); CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId]; System.assertEquals(CRON_EXP, ct.CronExpression); System.assertEquals(0, ct.TimesTriggered); Test.stopTest(); } }
Steven Nsubuga