
public class AccountTriggerHandler {
public static void CreateAccounts(List<Account> acclist){
for(Account a:acclist){
if(a.ShippingState!=a.BillingState){
a.BillingState=a.ShippingState;
}
}
}
}
trigger AccountTrigger on Account (before insert)
{
if (Trigger.isBefore && Trigger.isInsert) {
AccountTriggerHandler.CreateAccounts(Trigger.new);
}
}
@isTest
public class AccountTriggerTest {
@isTest static void TestCreate200Records(){
// Test Setup data
// Create 200 new Accounts
List<Account> accts = new List<Account>();
for(Integer i=0; i < 200; i++) {
Account acct = new Account(Name='Test Account ' + i, BillingState = 'CA');
accts.add(acct);
Test.startTest();
//insert acct;
Test.stopTest();
for (Account a:accts){
System.assertEquals('CA', a.ShippingState, 'ERROR');
}
}
}
}
And this error :
Challenge Not yet complete... here's what's wrong:The 'AccountTrigger' Trigger does not appear to be working correctly. Inserted records did not have matching BillingState and ShippingState values.Anyone can help me please??Thanks!

As per my understanding, you should place "a.ShippingState"(in CreateAccounts method) on left side as per requirement mentioned.Fr eg,a.ShippingState = a.BillingState;Please let me know if it helps.