You need to sign in to do that
Don't have an account?
test class help related to code that used to work before but doesn't work now
WHEN i RUN THIS PART OF THE CODE IT GIVES ME THE BELOW ERROR ALTHOUGH IT USED TO WORK BEFORE
if(a[0].Product_Family__c == '360 Suite'){
a[0].Status = 'Canceled';
}
error:
System.ListException: List index out of bounds: 0
if(a[0].Product_Family__c == '360 Suite'){
a[0].Status = 'Canceled';
}
error:
System.ListException: List index out of bounds: 0
It looks like you have empty list and you are trying to "Product_Family__c " from the 0 index of empty list. Please make sure you are inserting the records properly on Test class or check the debug logs for any exception while inserting record.
If it doesn't help then please share your code.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
All Answers
Please check the size of list is empty or not.
https://help.salesforce.com/articleView?id=000181121&type=1
Thank you.
It looks like you have empty list and you are trying to "Product_Family__c " from the 0 index of empty list. Please make sure you are inserting the records properly on Test class or check the debug logs for any exception while inserting record.
If it doesn't help then please share your code.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha