Skip to content

Instantly share code, notes, and snippets.

@arun12209
Created January 23, 2023 03:31
Show Gist options
  • Save arun12209/84ca546ea4ce0f69b4047b4030b15606 to your computer and use it in GitHub Desktop.
Save arun12209/84ca546ea4ce0f69b4047b4030b15606 to your computer and use it in GitHub Desktop.
@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