-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DUPLICATE_VALUE: duplicate value found #10
Comments
Hello @andrii-solokh I you trying to link to the same object, you can do that in two steps like this example Create 10 Cases related to 10 AccountsCreate a list of Acount sObjects and link them to a list of 10 Case sObjects List<Account> accList = TestDataFactory.createSObjectList('Account', new Map<String,Object>{
'Description' => 'Account Description'
},10); List<Case> caseList = TestDataFactory.createSObjectList('Case', new Map<String,Object>{
'Account' => AccList,
'Contact.Account' => AccList
},10); |
@benahm
In this situation, if you try to create AObj__c with only one action 'TestDataFactory.createSObject', it will produce error, because DObj__c will have same default name 'test0'. |
Hello @andrii-solokh I would do it like this
Hope this help. |
Ye, but if those should be different records, not same. And also if you don't care, just need to create test data as fast as possible, using one line.
I think that could be useful. |
I ran into this just trying to get all the tests in |
Hello, getting this error while running tests.
Seems 'TestDataFactory' doesn't count sames object number, and if creating record which depends on object 'X' and object 'Y' which depends also on 'X', two objects of 'X' will be created, but with same 'Name', that is causing my error.
It simply solved by specifying the name for one of 'X' objects, so another 'X' is default 'test0'.
It would be great to make the counter, to prevent this error.
The text was updated successfully, but these errors were encountered: