You need to sign in to do that
Don't have an account?
Kumar G
I have created the Test class mentioned in the code sample it's having only 69% of code coverage , plz suggest me how to increase code coverage.
How to improve code coverage for AddError method and Wrapper class
@isTest(seeAllData=true) private class Test_OpportunityLineItemCheck { static testMethod void Checkduplicate() { Test.startTest(); Account accP = new Account(Name = 'Partner1', Account_Type__c = 'VAR - MANAGED', RecordTypeId='01280000000Ln6i', Business_Unit__c = 'CBU'); insert accP; PricebookEntry[] pbes = [Select Id, UnitPrice, CurrencyIsoCode, Pricebook2Id from PricebookEntry where IsActive = true AND UnitPrice > 0 AND CurrencyIsoCode = 'USD' AND Name like 'UK%']; Opportunity opp4 = new Opportunity(Name= 'Opp31',Pricebook2Id = pbes[0].Pricebook2Id,RecordTypeId = '01280000000Lnks'); insert opp4; OpportunityLineItem oli4 = new OpportunityLineItem(OpportunityId = opp4.Id, PricebookEntryId = pbes.get(0).Id, Quantity = 1, SBA_Price__c=20, GovEd__c=0, Partner_Discount__c=0, Promo_Discount__c=0, Deal_Reg_Discount__c=0); OpportunityLineItem[] olilist=new OpportunityLineItem[]{oli4}; insert olilist; OpportunityLineItemCheckOperations.OppWrapper empW = new OpportunityLineItemCheckOperations.OppWrapper(); empW.compareTo(empW); Test.stopTest(); } }
I have created the Test class mentioned in the code sample it's having only 69% of code coverage , plz suggest me how to increase code coverage.
Could you please highlight the section which is not being covered by your test class.
Thanks,
If yes, is your trigger on Opportunity?
Yes it's an helper class , trigger is on OpportunityLineItem.
Apex Trigger :
trigger OpportunityLineItemCheck on OpportunityLineItem (before insert)
{
opportunityLineItemCheckOperations.checkOnOpportunityLineItems(trigger.new);
}
Thanks.,
Please assign values to wrapper class fields :
OpportunityLineItemCheckOperations.OppWrapper empW = newOpportunityLineItemCheckOperations.OppWrapper();
empW .OppID = opp4.id;
empW .OppID = '12347';
empW.compareTo(empW);
Please check once above code and let me know code work or not.
Thanks
Varaprasad
I have checked with the above code i am getting the below error :
Compile Error: Variable is not visible: OpportunityLineItemCheckOperations.OppWrapper.OppID at line 29 column 15
Thanks
Naveen
Add public to your strings in wrapper class :
public String OppID;
public String ProductID;
public String productcode;
Thanks
Varaprasad
I have added public to strings and assigned values to wrapper fields this time no error but code coverage is showing remains same.
empW .OppID = opp4.id;
empW .productcode = 'FA311';
empW.compareTo(empW);
Thanks,
Naveen
Any idea on this.
Thanks..