Ok, so I have some code that will segment the duplicate record sets generated by the system. To give an example, in case all contacts of a duplicate record set are of a certain type, it goes to team X to de-dupe these contacts.

I was writing my test coverage for this and noticed that even though when querying for the active duplicate rules - which it finds - the rules don't seem to be generating the actual duplicate record sets and items... Anyone else noticed this issue? Any way to have those rules generate the sets and items?

To be clear, the rules are there and are working cause if I don't use this dml option: DuplicateRuleHeader.AllowSave = true, at first, it wouldn't let me insert my second (duplicate) contact...

  • so, in the testmethod, querying for DuplicateRecordSet brings back no rows? If so, then to test this you'll need to restructure your code so that the Prod code calls an interface implementation that does the SOQL and returns sobjects whereas the testmethod has its own implementation of the interface that it injects into the prod code before starting the test. The testmethod's implementation returns constructed (not queried) sobjects.
    – cropredy
    Mar 6, 2016 at 7:30
  • Hey Koen. Did you find a solution to this? Struggling with the exact same problem now
    – Novarg
    Jan 18, 2017 at 12:55


You must log in to answer this question.

Browse other questions tagged .