You need to sign in to do that
Don't have an account?
TeamFugu
SOQL Statement Not Executing When Called From Test Class
I've run into problems where SOQL queries are not returning data when I'm running a test. I can copy the query string into either the Developer Console or using the Force.com IDE and the query returns the data. I see in documentation where the sample code for testing has a query in it so I think it should work. Do I need to elevate the user for the test or something? Or is this normal?
All Answers
If you need the query to return live data, use @isTest(SeeAllData=true). This is not recommended; your test methods should create any records they need to operate correctly from scratch, and leave SeeAllData as false. This reduces false errors and helps isolate your code's logic from external data.