I like to see you keep your test classes private. I always recommend this since tests should never interfere with production code.
@AlbaRivasSalesforce10 ай бұрын
Note on using fake Ids: I was wrong!! --> standard objects Id prefixes don't change from org to org, but custom objects do, and I had completely forgotten this. This is a solution to get a fake Id dynamically, that won't fail when you move the test to a different org: /** * @description getFakeId * @summary Generates a record Id for an SObjectType without having to insert a record. * @param sobjType The Schema.SObjectType * @param startNumber * @return String value */ public static String getFakeId(Schema.SObjectType sobjType, Integer startNumber) { String result = String.valueOf(startNumber++); return sobjType.getDescribe().getKeyPrefix() + '0'.repeat(12 - result.length()) + result; } You can also check salesforce.stackexchange.com/questions/21137/creating-unit-tests-without-interacting-with-the-database-creating-fake-ids
10 ай бұрын
Live starts at 14:59. You're welcome.
@philw474010 ай бұрын
Glad to see something about fake IDs, but you seemed to miss covering mocking methods and classes. You stuck with static methods being tested, which, as you know, cannot be mocked. It would be good to do a session focused on a unit testing mocking framework.
@AlbaRivasSalesforce5 ай бұрын
Yes!! That's my plan, when my other priorities let me :)