You need to sign in to do that
Don't have an account?
K@S
testclass error
Hi team,
I face this error
System.AssertException: Assertion Failed: Missing id at index: 0
I want to delete the item time through the error in.
please help on this
static testMethod void Testtems(){
User u2 = TestCaseHelpers.usrMethdLstWithProfileNameAndRoleName(2, 'Super System Admin', 'Nicole Team')[0];
System.runAs(u2){
list<OpportunityLineItem> oliList = new list<OpportunityLineItem>();
//Create test line item
OpportunityLineItem oliInst = new OpportunityLineItem();
oliInst.OpportunityId = op.Id;
oliInst.ServiceDate = startDate;
oliInst.Quantity = 1;
oliInst.UnitPrice = 1;
oliInst.AB2__ABDropID__c = '-1';
oliList.add(oliInst);
insert oliList;
try{
delete oliList;
}
Catch(ListException e){
System.assert(e.getMessage().contains('Error:You are trying to delete Opportunity Line Item(s) that have delivery; this function is not allowed here'),e.getMessage());
}
}
}
I face this error
System.AssertException: Assertion Failed: Missing id at index: 0
I want to delete the item time through the error in.
please help on this
static testMethod void Testtems(){
User u2 = TestCaseHelpers.usrMethdLstWithProfileNameAndRoleName(2, 'Super System Admin', 'Nicole Team')[0];
System.runAs(u2){
list<OpportunityLineItem> oliList = new list<OpportunityLineItem>();
//Create test line item
OpportunityLineItem oliInst = new OpportunityLineItem();
oliInst.OpportunityId = op.Id;
oliInst.ServiceDate = startDate;
oliInst.Quantity = 1;
oliInst.UnitPrice = 1;
oliInst.AB2__ABDropID__c = '-1';
oliList.add(oliInst);
insert oliList;
try{
delete oliList;
}
Catch(ListException e){
System.assert(e.getMessage().contains('Error:You are trying to delete Opportunity Line Item(s) that have delivery; this function is not allowed here'),e.getMessage());
}
}
}
I am curious as to where op.id comes from at this line:
Obviously a line item needs an opportunity, but you arn't setting one up in this testMethod? That would cause the insert to fail, but I'm not sure why that doesn't kick off it's own exception when you try to insert the list.