You need to sign in to do that
Don't have an account?
mstarks
Test class is no longer recognizing an inserted test Account record
In a test class, create an Account with a unique name. Next, create an Id variable and attempt assigning the variable by selecting the Account by the unique name. Error returns - list has no rows for assignment to sObject.
All Answers
Try something like below ans see if that helps :
Hope that helps!
One thing to notice is that, for Test Classes, whatever the data records we create will not be stored in database, but you can only refer to them in present context in test class.
Note: Mark this as solution if that helps.
Try something like below :
Now in your TEST Class:
Hope this help!
@testSetup static void setup()
Each time when the class being tested attempts to select the inserted test account record, it is not found. This is happening across any classes using Account records in test classes. Other types of records (both standard and custom) are selected without a problem. Strange.
I would like to take a look at it and see if I could investigate further.
I actually encounter the same issue with a custom object in a full sandbox after it was upgraded to Summer 16. It must be related to the Summer 16 release, because all the tests are being executed every night via Jenkins and they only started to fail after the upgrade.
Here is one of the tests that is failing now.
The query returns List has no rows for assignment to SObject. When I add "ALL ROWS" to the query, it seems to find the record, but the isDeleted flag indicates false. There is also no delete logic for the object, so that also can't be the cause.
It appears that when I add certain fields to the SELECT section, it will return the record. The below queries all result in the error.
For instance the field Action_Code__c seems to be a non-problematic field, so the following queries will return the record without any issue.
Thanks for any help in advance.
Here is sample code that produces issue for us:
Account a = new Account();
a.Name = 'Test';
a.Global_Region__c = 'North America';
a.Global_Sub_Region__c = 'SMB1';
a.BillingState = 'OH';
insert a;
Id acctId = [select Id from Account where Name = 'Test'].Id;
mstarks, do you have a skinny table enabled for the Account object?
https://developer.salesforce.com/blogs/engineering/2013/03/long-and-short-term-approaches-for-tuning-force-com-performance.html
Our full sandbox is on cs87. In our case it does seem to be related to the skinny tables according to support. They recognized it as a known issue: https://success.salesforce.com/issues_view?id=a1p3A000000IXfz They expect to push the patch around the middle of next week.