You need to sign in to do that
Don't have an account?
SOQL Statement Not Executing When Called From Test Class
Hello,
I have a SOQL statement in my main class which executes correctly apart from when called from a test class. The SOQL statement returns no results when I execute it from the test class. If I run the SOQL directly in the salesforce.schema window of my Force.Com IDE the SOQL runs ok and returns results ok. I run this as a Sys Admin & when I execute the test class I'm logged in as this same user. The permissions are not set to read only for the Sys Admin user for the fields in my object which I am querying on. I am executing this in my developer box.
Is it possible that Test classes cannot execute a soql query in developer edition?
As the fields are not read only on the object. is there another setting on the object which may block SOQL statements from being run?
Thanks.
Hi
Seems like you have data accessibility issue in your test class you need to use
IsTest(SeeAllData=true)http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_annotation_isTest.htmPlease mark it closed if above solve your issue
All Answers
Hi
Seems like you have data accessibility issue in your test class you need to use
IsTest(SeeAllData=true)http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_annotation_isTest.htmPlease mark it closed if above solve your issue
As per the last updates in Spring'11, test methods will not take data from the Org unless we specify the "SeeAllData = true" attribute. So I guess you are not making any test records for the object on which the query is executed, and hence it returns ZERO results. You need to create data in your test methods.
Thank you Vishal & Abhay for your help.