You need to sign in to do that
Don't have an account?
Vishwanath
Problem in test coverage
Hi,
how to write test case for below code
List<A__c> pay=new <A__c>(); pay=[select id,name,Year__c,Event__c from A__c where parent__c=:ppid]; for(A__c rh:trigger.new) { for(A__c p:pay) { if(p.Year__c==rh.Year__c && p.Event__c==rh.Event__c) { Trigger.new[0].Year__c.addError(''+rh.Year__c+'Report is Created'); } } }
Thaks..
You have to perform the DML operation(the operation on which your trigger is executing, i..e Insert/Update/Delete) on the object A__c in the test class.
For the syntax of test class please visit the below link
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
Thanks,
Hi,
What is the ppid and how it is related to A__c. Please more elaborate your trigger code.
So that we can give you exact solution.
Hi Navatar ,
it is parent object id, List pay contains list of records depending on the parent id
Hi,
In the test method create one record for parent object with your field
Like:
Account a=new account(name=’ab’);
Insert a;
Then insert records for child object
A__c acobj1=new A__c(Year__c=’2011’,Event__c=’evnt’ parentobjid=a.id);
Insert acobj1;
A__c acobj2=new A__c(Year__c=’2011’,Event__c=’evnt’ parentobjid=a.id);
Insert acobj2;
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.