Skip to content

Test failure: duplicates detected

Detection

  • String: DUPLICATES_DETECTED
  • Applies to: Apex test failures

Examples

  • System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATES_DETECTED, Use one of these records?: []

Resolution

A duplicate rule of the target org blocks the test data.
- Make the test data unique (names, emails, phone numbers...)
- Or insert it with Database.DMLOptions, with DuplicateRuleHeader.allowSave = true

Comments