You need to sign in to do that
Don't have an account?
kullayappa Adapala
how to cover the test class for Loop?
How to Cover the test class for Loop?
@istest Private class dummy_email_testclass{ static testMethod void dummy_email_testclassa(){ Contact con=new Contact(); COn.Lastname='test'; con.Email='test@gmail.com'; insert con; update con; } }
Insert both the record as your trigger fires on insert not on update, don't insert one and update other.
Thanks,
Aman
All Answers
In the above code, the reason why for loop is not covering is because your map 'varmap' is empty. and this is empty because you don't have enough(more than one record) data.
So, you must have to create atleast 2 contact test record in your test class to cover your test code. Kindly give it one more try with 2 record.
Please mark the answer as best if this helps.
Thanks,
Aman
Please Try the following test class it covers your class 88% because you are using adderror method that fails in test class so iam adding test.isrunningtest() in your apex trigger.
Apex Trigger
Apex test class
Mark as a best if helpfull to you
Regards,
Suraj
I have used which you have provided the code , but it is not working and for loop is not covered in the test class.
Thanks
kullayappa
Insert both the record as your trigger fires on insert not on update, don't insert one and update other.
Thanks,
Aman
Thank you so much for your helping
Hi Kullayappa Adapala,
Please check my test class because which test class you provided that is not mine and it is inserting with contactID that can not be possible.
Please make us confirm
Thanks