收藏Jagriti Kukreti (RBC) 提问于 #Apex2019年3月18日 14:52I am trying to cover the positive scenario of a class but i am receiving assetion fail error.I am trying to cover the positive scenario of a class but i am receiving assetion fail error. Kindly helpClass: public class CTICallInitiationService { public static Id createServiceSessionRecord(String route, String callFrom, String customerType, String language, String branchPhone, String highestAuth, String trustedPhone){ Service_Session__c serviceSessionRecord = new Service_Session__c(); //serviceSessionRecord.Account_ID__c = accountId; serviceSessionRecord.Session_Type__c = 'Phone'; serviceSessionRecord.Highest_Authentication_Level_Achieved__c = highestAuth; serviceSessionRecord.Authentication_Level__c = highestAuth; //serviceSessionRecord.Parent_Case__c=idCase; serviceSessionRecord.Created_Date_Time__c = System.now(); serviceSessionRecord.Status__c = 'Active'; serviceSessionRecord.Initiating_User__c = UserInfo.getUserId(); serviceSessionRecord.Call_Route__c = route; serviceSessionRecord.Call_From_ANI__c = callFrom; serviceSessionRecord.Customer_type__c = customerType; serviceSessionRecord.Language__c = language; serviceSessionRecord.Branch_Phone__c = branchPhone; serviceSessionRecord.trusted_phone__c = trustedPhone; try { insert serviceSessionRecord; } catch(DmlException e) { serviceSessionRecord.id = null; System.debug('The following exception has occurred: ' + e.getMessage()); } return serviceSessionRecord.id; } } Test Class:@isTest(seeAllData=false)private class CtiCallInitiationServiceTest { @isTest private static void ServiceSessionRecordTest(){ /* Positive insertion */ Id idSession1 = CtiCallInitiationService.createServiceSessionRecord('route', 'callFrom' , 'customerType' , 'language' , 'branchPhone' , 'highestAuth' , 'trustedPhone'); /* Negative insertion */ Id idSession2 = CtiCallInitiationService.createServiceSessionRecord('test', '9080942889' , 'Consumer' , 'Test' , '9080942889' , 'Full' , 'Yes'); Test.startTest(); system.assertEquals(False, String.isBlank(idSession1)); system.assertEquals(true, String.isBlank(idSession2)); Test.stopTest(); } }显示更多3 个回答排序按日期排序按最有帮助排序按日期排序加载更多评论...Jagriti Kukreti (RBC)2019年3月19日 06:04@Raj Vakati : but i need to keep idSession1 for positive case scenario添加评论撰写回答...粗体斜体下划线删除线项目符号列表编号列表添加链接代码块插入图像附加文件链接 URL取消保存0/9000回复
Jagriti Kukreti (RBC)2019年3月19日 06:04@Raj Vakati : but i need to keep idSession1 for positive case scenario