Created
November 20, 2017 15:41
-
-
Save scottmcclung/b44062eb6ff7c31fa878074c5ae91543 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