Skip to content

Instantly share code, notes, and snippets.

Created January 23, 2023 03:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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