-
-
Save doppiomacchiatto/7c43c8d6771289ff3249fcefc647aa33 to your computer and use it in GitHub Desktop.
Apex method to generate fake record ids in tests.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Apex method to generate fake record ids in tests | |
* Created by Stephen Willcock | |
* https://foobarforce.com/2013/08/15/apex-method-of-the-day-string-repeat/ | |
*/ | |
public class TestUtility | |
{ | |
static Integer s_num = 1; | |
public static String getFakeId(Schema.SObjectType sot) | |
{ | |
String result = String.valueOf(s_num++); | |
return sot.getDescribe().getKeyPrefix() + | |
'0'.repeat(12-result.length()) + result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment