You need to sign in to do that
Don't have an account?
sfdc dev 2264
SALESFORCE APEX TEST COVERAGE HELP NEEDED
Hi,
I need help on the below lines to cover in my test class , its not entering the if conditiona nd the coverage is 60%
if(!allLinksMap.isEmpty()){
labelList.addAll(allLinksMap.keySet());
for(String labelLink : labelList){
Custom_Links_For_Lightning__c myCustomSetting = allLinksMap.get(labelLink);
mapLabelLink.put(myCustomSetting.Home_page_Header_Section__c+'_'+myCustomSetting.Label_for_Custom_Link__c,myCustomSetting.Links_for_Home_Page__c);
}
Pls help me , thanks
I need help on the below lines to cover in my test class , its not entering the if conditiona nd the coverage is 60%
if(!allLinksMap.isEmpty()){
labelList.addAll(allLinksMap.keySet());
for(String labelLink : labelList){
Custom_Links_For_Lightning__c myCustomSetting = allLinksMap.get(labelLink);
mapLabelLink.put(myCustomSetting.Home_page_Header_Section__c+'_'+myCustomSetting.Label_for_Custom_Link__c,myCustomSetting.Links_for_Home_Page__c);
}
MY APEX CLASS : public with sharing class BAU_CustomLinkForLightning { public static Map<String,String> mapLabelLink = new Map<String,String>(); @AuraEnabled public static Map<String,String> getCustomLinks(){ system.debug('inside code***'); Map<String, Custom_Links_For_Lightning__c> allLinksMap = Custom_Links_For_Lightning__c.getAll(); List<String> labelList = new List<String>(); if(!allLinksMap.isEmpty()){ labelList.addAll(allLinksMap.keySet()); for(String labelLink : labelList){ Custom_Links_For_Lightning__c myCustomSetting = allLinksMap.get(labelLink); mapLabelLink.put(myCustomSetting.Home_page_Header_Section__c+'_'+myCustomSetting.Label_for_Custom_Link__c,myCustomSetting.Links_for_Home_Page__c); } system.debug('ALL LABEL LINK VALUES***'+mapLabelLink); } return mapLabelLink; } }
MY TEST CLASS @isTest public class BAU_CustomLinkForLightningTest { @testsetup static void createData(){ List<QantasConfigData__c> lstConfigData = new List<QantasConfigData__c>(); lstConfigData.add(TestUtilityDataClassQantas.createQantasConfigData('Log Exception Logs Rec Type','Exception Logs')); insert lstConfigData; TestUtilityDataClassQantas.createQantasConfigDataAccRecType(); } public static testmethod void getCustomLinkstest() { system.debug('*****insidemethod*******'); //TestUtilityDataClassQantas.enableTriggers(); BAU_CustomLinkForLightning bau = new BAU_CustomLinkForLightning(); BAU_CustomLinkForLightning.getCustomLinks(); List<Custom_Links_For_Lightning__c> custlinklightning= new List<Custom_Links_For_Lightning__c>(); custlinklightning.add(new Custom_Links_For_Lightning__c(Name='A380 Cabin Update Fact sheet',Home_page_Header_Section__c='Essential Reading',Label_for_Custom_Link__c='A380 CA380 Cabin Update Fact sheet',Links_for_Home_Page__c='https://www.qantasnewsroom.com.au/wp-content/uploads/2017/08/A380-Cabin-Update-Fact-Sheet.pdf')); system.debug('*****custlinklightning******'+custlinklightning); insert custlinklightning; } }
Pls help me , thanks
Try to update your test class with below snippet: Hope this will help. Kindly let me know in case any query.
Thanks,
Aman
All Answers
Try to update your test class with below snippet: Hope this will help. Kindly let me know in case any query.
Thanks,
Aman