You need to sign in to do that
Don't have an account?
mxalix258
Help with test class on trigger
Can anyone help me with the below test class? It is for a trigger that creates a new record in the "Onboarding" object based off criteria in the "Application__c" object.
Here is the test class as I have it now, but I am getting an error of "Error: Compile Error: unexpected token: 'insert' at line 13 column 8"
@isTest private class OnboardingTest { static testMethod void myOnboardingTest() { Account a=new Account(); a.Name='ob test account'; insert a; Contact con=new Contact(); con.Lastname='onboarding contact'; con.AccountId=a.Id insert con; Job__c job=new Job__c(); job.Name='Test job1'; insert job; test.startTest(); Application__c app=new Application__c(); app.RecordType='012C0000000Bhsc'; app.JobId=job.Id insert app; app.Stage__c='Signed'; update app; test.stopTest(); } }
You need a semi colon after line 12
All Answers
You need a semi colon after line 12
That worked - thank you! Is there any way to edit this code so that it covers the dml exception in the trigger as well? When i try to create another contact, and leave out information like last name, it hits the dml exception when I do the test class, but it doesn't provide any code coverage either. Any ideas?
It depends on the trigger. If the trigger is a before trigger then you can check for that but if it is an after trigger then the platform will handle the error first.