Skip to content

TestFactory and unique Fields. #640

@Otmaro

Description

@Otmaro

Summary

I am missing functionality on TestFactory class for objects with unique fields.

At this moment I have a field on Account which is both unique and required. I have set this unique field in TestFactoryDefault with random number generation.

This is OK for creating several records as long as I use different createSObject calls, but when I use createSObjectList, all records are generated with the same random number so it fails to create the records.

I have noticed that TestFactory is ready to handle this poblem with Name field but it seems it is not ready to work on any other unique field (or maybe I am doing something wrong?)

I try to avoid using createSObjectList because of this, but this method is used in other apex-recipes tests like CollectionUtil_Tests and therefore I need to modify them.

Suggested Solution

Would it be possible to add something to handle list generation for objects with unique fields?

Alternative Solutions

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions