You need to sign in to do that
Don't have an account?
Ryan Sloan 7
SOQL Query returning 0 Rows
The query
[SELECT Id FROM Contact]
is returning zero rows in a test class.
I have tried everything I can think of. Why won't it return all records?
When I run the test I am seeing this line in the log.
SOQL_EXECUTE_BEGIN [4]|Aggregations:0|SELECT Id FROM Contact
SOQL_EXECUTE_END [4]|Rows:0
[SELECT Id FROM Contact]
is returning zero rows in a test class.
I have tried everything I can think of. Why won't it return all records?
When I run the test I am seeing this line in the log.
SOQL_EXECUTE_BEGIN [4]|Aggregations:0|SELECT Id FROM Contact
SOQL_EXECUTE_END [4]|Rows:0
Let us know if this will help you
Thanks
Amit Chaudhary
I think this will help you.
@isTest
public class testClassForContacts{
private void fetchAllContacts(){
account accountObj = new account();
accountObj.name = 'Account Example';
insert accountObj;
contact contactObj = new contact();
contactObj.firstName = 'Contact';
contactObj.lastName = 'Example';
contactObj.accountid = accountObj.id;
insert contactObj;
List<contact> listOfContacts = [SELECT Id,accountId FROM Contact] ;
}
}
Let me know if any queries.
Thanks