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 MyTestClass { | |
static testMethod void testMyMethod() { | |
// BAD PRACTICE: Hard-coding test data | |
Account a = new Account(Name='Test Account', Industry='Technology'); | |
insert a; | |
System.assertEquals('Test Account', a.Name); | |
System.assertEquals('Technology', a.Industry); | |
// GOOD PRACTICE: Using variables for test data | |
String accountName = 'Test Account 2'; | |
String industry = 'Finance'; | |
Account b = new Account(Name=accountName, Industry=industry); | |
insert b; | |
System.assertEquals(accountName, b.Name); | |
System.assertEquals(industry, b.Industry); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment