Last active
February 5, 2018 09:59
-
-
Save samuel-alves/fe54a6b08723175aa84b6a07cde5c34b to your computer and use it in GitHub Desktop.
Tips to writing good Unit Tests https://developer.salesforce.com/blogs/developer-relations/2016/07/six-tips-great-unit-tests.html
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 static void User_can_get_contact_email() | |
{ | |
// Arrange | |
System.runAs(createUser()) | |
{ | |
// Act | |
// Assert | |
system.assertEquals('contact@place.com', contact.Email, 'Email does not match'); | |
} | |
} | |
public static User createUser() | |
{ | |
Profile profile = [select Id from profile where name = 'Standard User']; | |
User user = new User( | |
Alias = 'standard', | |
Email = 'standarduser@testorg.com', | |
EmailEncodingKey = 'UTF-8', | |
LastName = 'Testing', | |
LanguageLocaleKey = 'en_US', | |
LocaleSidKey = 'en_GB', | |
ProfileId = profile.Id, | |
TimeZoneSidKey = 'Europe/London', | |
UserName = 'standardusertesting@gearsettest.com' | |
); | |
return user; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment