This is my Code and I have verified that this is the only trigger that is active and there are no Account related Flows active.
(1)
public class AccountTriggerHandler {
public static void CreateAccounts(List<Account> mAccounts){
if (mAccounts.size() > 0){
List<Account> tempAccounts = new List<Account>();
for(Account a : mAccounts){
if (a.ShippingState == a.BillingState){
tempAccounts.add(new Account(Name = a.Name,BillingState = a.BillingState, ShippingState = a.ShippingState));
}
}
if (tempAccounts.size() > 0){
try{
insert tempAccounts;
} catch (DmlException e) {
System.debug(e.getCause());
}
}
}
}
}
(2)
trigger AccountTrigger on Account (before insert) {
if (Trigger.isBefore && Trigger.isInsert) {
AccountTriggerHandler.CreateAccounts(Trigger.New);
}
}
(3)
@isTest
public class AccountTriggerTest {
@isTest
public static void TestCreateNewAccountInBulk(){
List<Account> accts = new List<Account>();
for(Integer i=1; i < 201; i++) {
accts.add(new Account(Name='Test Account TF' + i, BillingState ='CA', ShippingState ='CA'));
}
Test.startTest();
insert accts;
Test.stopTest();
List<Account> verifyAccts = [SELECT Id FROM Account];
System.assertEquals(200, verifyAccts.size());
}
}