Skip to content

Test failure: validation rule

Detection

  • RegExp: FIELD_CUSTOM_VALIDATION_EXCEPTION, ([^:\n]*)
  • Applies to: Apex test failures

Examples

  • System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Invoice date is required: [Invoice_Date__c]

Resolution

A validation rule of the target org refuses the test data: {1}
- Fill the test data so it passes the validation rule
- Create the test data with a test data factory shared by the test classes, so one fix covers them all
- Run the test class on your org before publishing: sf hardis:org:test:apex

Comments