You need to sign in to do that
Don't have an account?
Test trigger help
I am writing my first trigger test: cover =0%
Message:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You Must Enter A Charge: []
Stack Trace
Class.TestUpdateCharge.testChargeContractTrigger: line 6, column 1
1@isTest
public Class TestUpdateCharge {
static testMethod void testChargeContractTrigger(){
Charge__c c = new Charge__c (City__c = 'Oakland');
insert c;
c = [select id,contract__c,Opportunity__c from Charge__c where City__c = 'Oakland'];
System.assertEquals(null, c.contract__c);
System.assertEquals(null, c.Opportunity__c);
}
}
Hi,
The Error message clearly says the Insert is Failed, Because of some validation.
Here by the insert statement you have written in test method didn’t insert the record.
The reason might be a validation rule exists on that object or some other mandatory fields on that object to form a record.
Please check those and make sure to insert record (charge__c) with required/proper data.