Skip to main content
8 events
when toggle format what by license comment
Mar 14, 2014 at 22:22 comment added Keith C Interesting about User - thanks for mentioning it.
Mar 14, 2014 at 22:18 comment added smohyee Fair point. Funny thing is I didn't have to use SeeAllData=true. I think maybe users count as metadata when it comes to Apex? After all, they are copied over in dev sandboxes, unlike most table records.
Mar 13, 2014 at 21:35 comment added Keith C You are probably right that it will work. Avoiding "magic" numbers generally leads to clearer code, in this case the insert of a named object; imagine in a years time when someone else has to work on your code which is clearer. Or would something break in this test (or another test) if the User is deactivated? Or might you want to use this code in a completely different org in the future? Generally relying on SeeAllData=true leads to fragile tests. But it is you and your team's choice.
Mar 13, 2014 at 21:03 comment added smohyee As to your PS, I'm not clear on why that's necessary, if the Sandbox copies users from Production as part of metadata, I shouldn't have to create a test user, should I?
Mar 13, 2014 at 21:02 comment added smohyee Your answer highlights the thing I had forgotten, that 'sRec1', aka the variable object I declared in the test, is not actually tied to the record created in salesforce after the dml statement. My system.Assert statements also tested against sRec values, as opposed to a SOQL query of the actual record, which is why my test wasn't passing.
Mar 13, 2014 at 21:00 vote accept smohyee
Mar 12, 2014 at 22:23 history edited Keith C CC BY-SA 3.0
added 169 characters in body
Mar 12, 2014 at 22:16 history answered Keith C CC BY-SA 3.0