You need to sign in to do that
Don't have an account?
teknicsand
Apex Test Class
User opp_owner = [select id, username, Profile.Name, email from User where id = :opp.OwnerId];
How do I test for the above query in a test class? When I call the function to which the above line belongs, in the test class, I get a "List has no rows for assignment to SObject" error.
Any thoughts or suggestions?
Thanks in advance..
Sand
Not my area of expertise, but I'd imagine you could do something like:
User u=new user();
insert u;
//assign required user fields u.name="name", etc; Opportunity o=new Opportunity(); //assign required opportunity fields o.userId=u.id; insert o; //call your method
User opp_owner = [select id, username, Profile.Name, email from User where id = :testopp.OwnerId];
Isn't an opportunity created in a test class assigned to any owner? The above line in the test class returns with no rows for list error. Testopp is created and inserted successfully. But when I try and query for an user who owns it, I get the error.
Am I missing something here?
I queried the opp I inserted. Too bad I can't look at the debug values, since the **bleep** debug log size reached its limit!!! :smileymad:
So are you saying that fields that are defaulted during the insert process wont be populated with anything?