New answers tagged

0

I had the exact same problem, even flagging (SeeAllData=false) explicitly. It appears that even in test cases SF validates the SKU across all product records. I got around it in my test classes by ensuring the product SKU was guaranteed to be unique & not match anything in an existing product record (in my case I appended 'SF-UNITTEST-' to all SKUs ...


3

This is happening because you are using the Database.insert() method with DMLOptions. The DMLOptions object contains a property called optAllOrNone. By default which is set to false. According to documentation. If optAllOrNone is set to true, all changes are rolled back if any record causes errors. The default for this property is false and ...


1

ld.Id is null because you aren't really inserting it. List<Lead> Leadld = New List<Lead>(); lead ld = new lead(); ld.RecordTypeId = '012p0000000Nn05AAC'; ld.Company = 'Google'; // ... snipped ... insert Leadld; The Lead object ld is not in the list Leadld, which is empty. Your insert therefore does nothing, and ld.Id ...


3

You're overcomplicating this for yourself. Your JSON-deserialization approach writes directly to the object's instance variables and does not invoke the setter methods, which are the only executable lines of code in this class. Also note that the testMethod annotation is deprecated (use @isTest), test methods don't return anything, and it sounds like you ...


Top 50 recent answers are included