You need to sign in to do that
Don't have an account?
Darb
test code error - list has no rows for assignment to SObject
I am trying to deploy a change set from a sandbox and an existing trigger is preventing me from doing so. The test does not have the required coverage. The error I get is System.QueryException: List has no rows for assignment to SObject. The test code is as follows:
@isTest private class LeadTriggerTest { static testMethod void LeadTest() { String testleadid=''; Lead testlead = new lead(); testlead.status='new'; testlead.lastname='Test'; testlead.company='Test'; testlead.description='test'; testlead.country='United Kingdom'; //get one user of proper type, use the where clause to filter user u=[select id,name from user where user.name='jonathan parker' LIMIT 1 ]; system.runas(u){ try{ insert testlead; testlead.country='Norway'; update testlead; testleadid=testlead.id; //if created correctly }catch(DMLException e){ system.assert(false, 'Error occurred inserting test record:'+e.getDMLMessage(0)); } } Lead checkcase = [select id,name from lead where id=:testleadid]; } }
You have to create that user in your test class first - by default test classes do not have any access to Production data, such as Users.
-Andy