How to create a fak...
 
Notifications
Clear all

[Solved] How to create a fake dummy id in salesforce for testing?

2 Posts
1 Users
0 Likes
262 Views
Posts: 205
 CWL
Admin
Issue starter
(@cwl)
Member
Joined: 11 years ago

How to create a fake dummy id in salesforce for testing, so you don't need to hard code?

Issue Tags
1 Reply
Posts: 205
 CWL
Admin
Issue starter
(@cwl)
Member
Joined: 11 years ago

If you need to create a properly formed Id and doesn't care about it actually being in the database for your apex test classes, you can create it as:

Id dummyId = SObjectType.My_Object__c.getKeyPrefix().rightPad(15, 0)
Reply
Share: