You need to sign in to do that
Don't have an account?
Test class throwing - System.QueryException: List has no rows for assignment to SObject
I'm receiving a query exception for the highlighted lines in red. When I run the test, it says my list has no rows. When I run the select query in the developer console i'm returning the correct value without a problem. You'll also note that in the RecordType line i'm performing the same logic with similar assignment. I'm not having any issues with this line so i'd expect that region should function exactly the same. Please note that pse__region__c is a lookup field though i wouldnt think this could be the problem if the SOQL query is returning the correct result in the developer console. Also, If I hardcode the id value of 'west', the test class will work fine. Obviously, you don't want to do this. Any help offered would be much obliged. #noob
//setup variables to be used for building projects. Region and Record type are required
//It is important not to hardcode these values as the Id's will differ in production
RecordType rectype = [Select id from RecordType where Name = 'Customer'];
pse__Region__c regtype = [select id from pse__Region__c where name = 'West' LIMIT 1];
//Setup the Project Record
pse__Proj__c p = new pse__Proj__c();
p.RecordTypeId = rectype.id;
p.Name='TestProject';
p.pse__Region__c == regtype.id;
p.pse__Is_Active__c = true;
insert p;
Hi
Test classes basically can't see data.
Does your test class have @isTest (seealldata=true) on the fefinition?
Even so, it may not deploy...Put code in your test clas to insert all data so your test can pas regardless of what's in SFDC (either sandbox or live).
All Answers
Hi
Test classes basically can't see data.
Does your test class have @isTest (seealldata=true) on the fefinition?
Even so, it may not deploy...Put code in your test clas to insert all data so your test can pas regardless of what's in SFDC (either sandbox or live).
Hi Kevin,
Thanks for the feedback. I did not have "(seealldate=true)." That fixed my problem! Thanks for the help.