I have searched for this error, but it seems specific to what your trying to do.
When i test this code on my sandbox, I get over 90% code coverage. When i push to my production environment, I get the following error:
System.QueryException: List has no rows for assignment to SObject Stack Trace: Class.TestFireFighterTickets_createFFticket.testFireFighter: line 6, column 1
Do I need a try catch exception for this to pass? If when i try using
try {
insert ftix;
} catch (system.Dmlexception e){
system.debug(e); }
It does not work
My apex trigger:
trigger FireFighterticketcreatorTrigger on Help_Desk_Ticket__c (after update) {
List<Firefighter__c> ftix = new List<Firefighter__c>();
for (Help_Desk_Ticket__c hd:trigger.new) {
if (hd.OwnerId == '0050B0000073uze')
{
Firefighter__c ff = new Firefighter__c ();
ff.Email_Address__c = hd.Email_Address__c;
ff.EmailFromName__c = hd.EmailFromName__c;
ff.OwnerId = '0050B0000073uze';
ff.Description__c = hd.Description__c;
ff.Title__c = hd.Title__c;
ff.Internal_Notes__c= hd.Internal_Notes__c;
ftix.add(ff);
} }
try {
insert ftix;
} catch (system.Dmlexception e){
system.debug(e);}}
My test class:
@isTest(SeeAllData=true)
private class TestFireFighterTickets_createFFticket {
static testmethod void testFireFighter() {
Test.startTest();
Help_Desk_Ticket__c hd = [
select id,
EmailFromName__c
from Help_Desk_Ticket__c
where OwnerId = '0050B0000073uze'
limit 1];
System.assert(hd != null);
hd.EmailFromName__c = '[email protected]';
update hd;
Test.stopTest();
List<Firefighter__c> ffs = [
select id
from Firefighter__c
where EmailFromName__c = :hd.EmailFromName__c];
System.assertEquals(1, ffs.size());
}}