You need to sign in to do that
Don't have an account?

How to make the TestCase successful.
Hi All,
I have a requirement, where in I need to delete all the Invoice Payment Line Items which has a specific record type. For which I have written a class. The class is working properly and we are getting the desired output, but when I am writing the test case the test case is failing and the code coverage is 54%.
Therefore I request you people to kindly suggest a solution such that the test case is successful and code coverage is above 75% as I need to migrate the code.
I am sending the code of both Apex class and as well as TestCase. Kindly look into the code and provide an appropriate solution.
Apex Class
Hi Arun,
in the testmethod, you should at least insert one instance of the Invoice_Payment_Line_Item__c object, i.e.
static testMethod void testMyController()
Invoice_Payment_Line_Item__c myInvoice = new Invoice_Payment_Line_Item__c(Name='testABC', RecordTypeId='01290000000Kex8', do initialization here);
insert myInvoice;
You should of course follow the best practices for writing test methods and writing code that doesn't hit SFDC-limits, which is explained in several resources available on the developer.force.com page. E.g. you should not call DML-method inside a for-loop.
Kind regards,
smash