Last active
August 29, 2015 14:14
-
-
Save zaki-yama/d64ee57be887ebbfab32 to your computer and use it in GitHub Desktop.
CreatedDateでのソートはアテにならない
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
@isTest | |
public class CreatedDateTest { | |
public static testMethod void run() { | |
Account a = new Account(); | |
a.Name = 'Account # 1'; | |
insert a; | |
System.debug(LoggingLevel.INFO, 'A\'s id: ' + a.id); | |
Account b = new Account(); | |
b.Name = 'Account # 2'; | |
insert b; | |
System.debug(LoggingLevel.INFO, 'B\'s id: ' + b.id); | |
// assertion | |
Account result = [SELECT Id FROM Account ORDER BY CreatedDate DESC LIMIT 1]; | |
System.debug(LoggingLevel.INFO, 'Result\'s id: ' + result.id); | |
System.assertEquals(b.id, result.id); // FAIL | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment