What is the result of the debug statements in testMethod3 when you create test data using testSetup in below code?
A. Account0.Phone=333-8781, Account1.Phone=333-8780
B. Account0.Phone=888-1515, Account1.Phone=999-2525
C. Account0.Phone=333-8780, Account1.Phone=333-8781
D. Account0.Phone=888-1515, Account1.Phone=999-1515
CRT-450: Salesforce Certified Platform Developer IFree dumps for CRT-450 in PDF format.High quality CRT-450 PDF and software. VALID exam to help you pass. |
@isTest
public class CommonTestSetup {
@testSetup static void setup() {
List testAccts = new List();
for(Integer i=0;i<2;i++) {
testAccts.add(new Account(Name = 'TestAcct'+i, Phone='333-878'+i));
}
insert testAccts;
}
@isTest static void testMethod1() {
Account acct = [SELECT Id,Phone FROM Account WHERE Name='TestAcct0' LIMIT 1];
acct.Phone = '888-1515';
// This update is local to this test method only.
update acct;
Account acct2 = [SELECT Id,Phone FROM Account WHERE Name='TestAcct0' LIMIT 1];
acct2.Phone = '999-1515';
// This update is local to this test method only.
update acct2;
}
@isTest static void testMethod2() {
Account acct = [SELECT Id,Phone FROM Account WHERE Name='TestAcct1' LIMIT 1];
acct.Phone = '888-2525';
// This update is local to this test method only.
update acct;
}
@isTest static void testMethod3() {
Account acc0 = [SELECT Id,Phone FROM Account WHERE Name='TestAcct0' LIMIT 1];
Account acc1 = [SELECT Id,Phone FROM Account WHERE Name='TestAcct1' LIMIT 1];
System.debug('Account0.Phone='+acc0.Phone);
System.debug('Account0.Phone='+acc1.Phone);
}
}
If the correction gaaad said was applied, then the answer is letter C
typo in line 9
should be: testAccts.add(new Account(Name = ‘MyTestAccount’+i, Phone=’333-878’+i));
the ins is B