You need to sign in to do that
Don't have an account?
William Woodson 3
Why do I see contacts in unit test, not using seeAllData
For some reason, my Contact object still shows existing contacts inside my unit tests even though I am not using seeAllData=true...
@isTest public class TravelDetailGateway_Tests { @isTest public static void loadData_Tests() { Test.loadData(Account.sobjectType, 'test_data_accounts'); //file contains 10 rows. //contact in file is associated to account 9 in the file above. Test.loadData(Contact.sobjectType, 'test_data_contacts'); //file coontains 1 row. integer acctCount = [SELECT count() FROM Account]; integer ctcCount = [SELECT count() FROM Contact]; system.assertEquals(10, acctCount); system.assertEquals(1, ctcCount); //assertion fails and returns 11 records. } }
Or
Check the data factory class properly is there any other contact insertion is happening when insert the account or any loop is there to insert the multiple contacts ( here your data factory class name is: Test)
Thanks,
Maharajan.C
All Answers
Thanks,
Matt
Or
Check the data factory class properly is there any other contact insertion is happening when insert the account or any loop is there to insert the multiple contacts ( here your data factory class name is: Test)
Thanks,
Maharajan.C
System.AssertException: Assertion Failed: Zero Contacts should exist - Line 7: Expected: 0, Actual: 10