Skip to content

Instantly share code, notes, and snippets.

@shinchit
Created September 18, 2019 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinchit/794f8a7ad112c4633caa14b05cda5c3d to your computer and use it in GitHub Desktop.
Save shinchit/794f8a7ad112c4633caa14b05cda5c3d to your computer and use it in GitHub Desktop.
@isTest
public with sharing class Some_Test {
@testSetup static void setup() {
Account acc = new Account(Name = 'account1');
insert acc;
System.debug(acc.Id); // We can confirm Account Id on the debug log.
}
@isTest static void testMethod1() {
List<Account> accs = [SELECT Id FROM Account];
for (Account acc : accs) {
System.debug(acc.Id); // We can confirm Account Id. NullPointerException is avoided!!
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment