You need to sign in to do that
Don't have an account?
Megan Moody 10
unit test query list has now rows
I am trying to write a unit test that tests the apex class used by a VF page. My list is returning no items even though my query should be valid.
The system.debug statement shows that the ID for the contact does exist. Any ideas why my query (right below the system.debug line at the top) is returning no rows?
The system.debug statement shows that the ID for the contact does exist. Any ideas why my query (right below the system.debug line at the top) is returning no rows?
System.runAs(testUser){ system.debug('objContact ID ' + objContact[0].id); Contact firstContact = [SELECT ID, firstname, Subscriber_ID__c, Member_ID__c FROM Contact WHERE ID = :objContact[0].id]; ConciergeDisplayFamilyMembers testFamily = new ConciergeDisplayFamilyMembers(new ApexPages.StandardController(firstContact)); ApexPages.StandardController sc = new ApexPages.StandardController(firstContact); Contact primaryContact = testFamily.currentContact; System.assertNotEquals(null, primaryContact); }
Karanraj
Megan - Make sure that runAs user in your test class have access to contact object. ('testUser')
doravmon
Are you sure the objContact[0].Id is the ID in the query ?