Timeline for How can Product2.StockKeepingUnit already exist in a test? [duplicate]
Current License: CC BY-SA 4.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 20, 2020 at 20:23 | history | closed |
Kris Goncalves identigral Rahul Gawale zuzannamj Mohith Shrivastava apex Users with the apex badge or a synonym can single-handedly close apex questions as duplicates and reopen them as needed. |
Duplicate of Unit Testing problem with Product2 records: A Product with this SKU already exists | |
Oct 15, 2020 at 8:08 | comment | added | Brian Kessler | Cheers for looking into it and giving feedback. | |
Oct 14, 2020 at 17:35 | comment | added | Kris Goncalves | I think the issue is that the test class is appropriately hiding the existing data when you query and execute a delete on it, but not when you're doing a dml for new objects. Ideally, it should be hidden for both situations. I tested in my sandbox and ran into the same issue but see no public known issue other than that question I linked | |
Oct 14, 2020 at 16:45 | comment | added | Brian Kessler | If there is data, shouldn't selecting and deleting all the data either purge the data or throw an error? Anyway, I'd prefer not to change the target of these tests without having tests.... (Really, I want to refactor the hell out of the target, but that's a different issue.) Is there an existing bug report where I can say this effects me? Is workaround the only possible solution? | |
Oct 14, 2020 at 16:34 | comment | added | Kris Goncalves | My fresh sandboxes come with product data which is why I believed it to be the same issue even with a fresh sandbox. If it is the issue, I don't disagree it's a bug/issue and leaves you in a bind. You'd have to look at mocking your SOQL against custom metadata to return different results that can rely on unique SKU product data or have specific records for just testing purposes denoted with an extra field | |
Oct 14, 2020 at 16:34 | review | Close votes | |||
Oct 20, 2020 at 20:23 | |||||
Oct 14, 2020 at 16:21 | history | edited | Brian Kessler | CC BY-SA 4.0 |
added 395 characters in body
|
Oct 14, 2020 at 16:19 | comment | added | Brian Kessler | @KrisGoncalves, Not really. 1. I am in a fresh sandbox which contains no data for it to otherwise match and 2. These values also need to match against Custom Metadata which can't (and shouldn't) be changed for the test. | |
Oct 14, 2020 at 16:07 | history | asked | Brian Kessler | CC BY-SA 4.0 |