Test Class runs successfully and test coverage is 100% but fails during deployment saying "Your Code Coverage is 70%".
@isTest
public class DefaultSignatureForEmail_Test {
static {
TriggerHandler.bypass('CaseTriggerHandler');
TriggerHandler.bypass('AccountTriggerHandler');
TriggerHandler.bypass('ContactTriggerHandler');
}
Static testMethod void TestDefaultSignatureForEmail() {
Account account = new Account();
account.name = 'test account';
account.Customer_Party_Id__c = '123456789';
insert account;
Contact contact = new Contact();
contact.AccountId = account.id;
contact.Email = '[email protected]';
contact.LastName = 'TestLastName';
insert contact;
List<Case> tCases = new List<Case>();
Case tCase = new Case(Subject = 'OneCase', AccountId = account.Id);
insert tCase;
Exception failureDuringExecution = null;
//Create QuickActionDefaults test data here
String defaultsAsJSON = '[{"targetSObject":{"attributes":{"type":"EmailMessage"},"TextBody":"",'
+ '"FromName":"Test","FromAddress":"[email protected]","HtmlBody":"<html><body></body></html>","BccAddress":"[email protected]",'
+ '"CcAddress":"","ToAddress":"[email protected]","Subject":"Testing"},"contextId":"'+tCase.Id+'","actionType":"Email",'
+ '"actionName":"Case.Email","fromAddressList":["[email protected]"]}]';
List<QuickAction.SendEmailQuickActionDefaults> defaultsSettings =
(List<QuickAction.SendEmailQuickActionDefaults>)JSON.deserialize(defaultsAsJSON, List<QuickAction.SendEmailQuickActionDefaults>.class);
Test.startTest();
try {
(new DefaultSignatureForEmail()).onInitDefaults(defaultsSettings);
}
catch(Exception failure) {
failureDuringExecution = failure;
}
Test.stopTest();
System.assertEquals(null, failureDuringExecution, 'There was an exception thrown during the test!');
}
}
but when other dev ran the same test, lines 20, 21 & 22 were showing not covered. I am not sure how is that happening. Could someone help me with how to set the templateId for SendEmailQuickActionDefaults in the test class?