You need to sign in to do that
Don't have an account?
Select not returning values
Below is a simple test I have written, all it suppose to do is a select an account and upsert it. No matter what I try I cannot get the select statement to any return values. I've opened it up to accept anything but it seems no matter what I do and not matter what object I try no records are returned.
I'm at a loss to why no values are returned when I am certain there are many rows. I am logged in as Platform sys admin when running these tests. I'm using force.com development environment.
Is there a limit or something in SF I'm running into or ??
Help me.. Will Robinson
public class ShareTriggerTestMethod
{
static testMethod void MySharingTest()
{
//get a acount to update
account acc = [select Id, name, comment__c from account limit 1];
acc.comment__c = 'test';
// upsert data causing the trigger to fire.
Test.startTest();
upsert acc;
Test.stopTest();
}
}
Begining with API 25 or so, your test methods do not have access to existing data unless you use the SEEALLDATA=true
It is best practice to create any records you are using in the test any way so, create and account and insert it, then your query will return a result.
All Answers
Begining with API 25 or so, your test methods do not have access to existing data unless you use the SEEALLDATA=true
It is best practice to create any records you are using in the test any way so, create and account and insert it, then your query will return a result.
Yep, what Starz26 said. but it's since api 24. Try to minimize the dependencies your test code has to records or configuration, ifnot, your tests can start failing when deleting/editing records of chaning configuration. Thats not a situation you want to run into.
Thanks much the info info!
The reason I was using existing data was I'm building a trigger to share salesforce to salesforce data and my test method was failing. I was told you had to use existing records that were already shared. However, I recently read sharing must be prod to prod or sandbox to sandbox.
Anyway thats a different issue, thanks for the assistance and information it's really appreciated...