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

Trigger test failure
Hi,
I'm writing a small apex class test for a trigger we have but when I run the test it fails with the error message "Missing id at index".
This is the test class below.
@istest
public class DeleteJunk_trigger_test {
public static testmethod void DeleteJunk_trigger()
{
test.startTest();
Registrations__c reg = new Registrations__c(GPRN__c = '', Source__c = '' , Source_System__c = '' , Region__c = '' ,
MPRN__c = '');
delete reg;
}
}
Can anyone see what I am missing?
Thanks.
You first need to insert a record before delete command. Here is the update code:
-Thanks,
TK
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
1) https://trailhead.salesforce.com/modules/apex_testing
Also please check below post
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_qs_test.htm
2) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_example.htm
3) http://amitsalesforce.blogspot.com/2015/06/best-practice-for-test-classes-sample.html
NOTE:- you need to insert data first then you can delete in your test class like below
Let us know if this will help you