You need to sign in to do that
Don't have an account?
Thomas Caillet
Number Of Revenue Installments in test trigger
Hi everybody,
I have to create a test code trigger to coverage my case trigger. But When I test it, I have this error : caused by: System.NullPointerException: Argument cannot be null.
In fact I have to fill the Number Of Revenue Installments and I don't know to do that when I create the product in my test.
Here is my test trigger :
Thomas
I have to create a test code trigger to coverage my case trigger. But When I test it, I have this error : caused by: System.NullPointerException: Argument cannot be null.
In fact I have to fill the Number Of Revenue Installments and I don't know to do that when I create the product in my test.
Here is my test trigger :
@isTest private class TestCreateBillingCaseonCase2 { @isTest static void TestCreateBillingCaseonCaseWithOpportunity() { // Test data setup // Create an account with an opportunity, and then try to delete it Opportunity opp = new Opportunity(Name='Opportunity TEST', StageName='Prospecting', AccountId='0012500000dVUEw', Starting_date__c=date.Today(), CloseDate=System.today().addMonths(1) ); insert opp; Quote QUOT = new Quote (Name='TEST',BillingCountry = 'France' ,BillingPostalCode = '75009' ,ContactId='0032500000YR74S',Unit_price_ex_VAT_per_room_booked__c=2,OpportunityId=opp.Id); insert QUOT; opp.SyncedQuoteId=QUOT.Id; opp.StageName='Closed Won'; update opp; Pricebook2 pb22 = new Pricebook2(Name='testDIE training'); insert pb22; Product2 pro2 = new Product2(Name='training', isActive=true, Billing_Type__c='Monthly'); insert pro2; PricebookEntry pbe2 =new PricebookEntry(unitprice=0.01,Product2Id=pro2.Id,Pricebook2Id=Test.getStandardPricebookId(), isActive=true,UseStandardPrice = false); insert pbe2; OpportunityLineItem OLI = new OpportunityLineItem (TotalPrice=240,opportunityId = opp.Id,Quantity=1,PricebookEntryId=pbe2.Id); insert OLI; Case ca = new Case(Subject='New hotel : Kick off',AccountId = opp.AccountId, Status ='in progress',Opportunity_Case__c = opp.Id); insert ca; // Perform test Test.startTest(); ca.Status='Closed'; update ca; Test.stopTest(); } }And here the trigger line where is my error :
Amount__c = (OLI.TotalPrice)/OLI.Number_Of_Revenue_Installments__c,Thanks very much
Thomas
And It's on line 50 (in the trigger not the test) that I have an error.
Thanks for your quick answer
to once and check. I think without populating Number_Of_Revenue_Installments__c field, it is null. So it will evaluate as
Amount__c = (OLI.TotalPrice)/null which gives attempt to deference null error.
Do I did something wrong ?
NOTE:Always try to write bulkified trigger.
Just for me,me question was : can I write the number of revenue installment in my test trigger when I create the product ??
here as I did, you can populate revenue installment field. ..