You need to sign in to do that
Don't have an account?
Jessica Clark 12
Test Class code coverage 71% -- not running if statement
I am creating a test class, and everything is running cleanly except one if statement. Although I am passing the correct string as an argument for the method, it is not recognizing it in the comparison statement. Below image is the code coverage, skipping if updateBoth == 'true'.
Test call: (note: I define o3, o, and c2 elsewhere; those are not an issue)
Controller method:
Test call: (note: I define o3, o, and c2 elsewhere; those are not an issue)
string refSource = 'Member Services'; string agentSource = 'Member Referral'; string refContact = '0030R00000SCIl3QAH';//jessica testclark string bCHLBool = 'true'; string priceRange = 'Test'; string areaInterest = 'Test'; string agentNotes = 'Test'; string description = 'Test'; string mortNotes = 'Need new Home'; string propAddr = 'Test123 City, ST 00000'; string mortStatus = 'In Process'; string mortType = 'Conventional'; string preQualBool = 'Yes'; string preQual = '100000'; string sendCU ='true'; string reasonNoCU = ''; string buyOrSell= 'Buy'; string buyOrSell2= 'Sell'; string updateBoth = 'true'; string updateBoth2 = 'false'; bAgentListController.updateOpportunity(o3.Id, refSource, agentSource, refContact, bCHLBool, priceRange, areaInterest, agentNotes, description, mortNotes, propAddr, mortStatus, mortType, preQualBool, preQual, sendCU, reasonNoCU, buyOrSell, 'true', o.Id, c2.Id);
Controller method:
@AuraEnabled //UPDATE OPPORTUNITY public static string updateOpportunity(string oppId, string refSource, string agentSource, string refContact, string bCHLBool, string priceRange, string areaInterest, string agentNotes, string description, string mortNotes, string propAddr, string mortStatus, string mortType, string preQualBool, string preQual, string sendCU, string reasonNoCU, string buyOrSell, string updateBoth, string otherOppId, string agentId ){ try{ Id RTID_Referred = RecordTypeManager.RecordTypeFor('Opportunity', 'Referred'); boolean sendCuBool = false; if (sendCU == 'true'){ sendCuBool = true; } boolean bCHLPass = false; if (bCHLBool == 'true'){ bCHLPass = true; } double preQualAmount = 0; if (preQual != ''){ preQualAmount = double.valueOf(preQual); } //UPDATE OPPORTUNITY Opportunity newOpp = [SELECT Id,Referral_Source__c, Agent_Source__c,Referring_Contact__c,Price_Range__c,Areas_of_Interest_city_state__c,Notes_for_Agent__c,Description,Mortgage_Notes__c,Closing_Address__c,Property_Street__c,Property_City__c,Mortgage_Status__c,Type_of_Mortgage__c,Pre_Qualified__c,Pre_Qualified_Amount__c,Send_To_CU__c,Reason_not_sent_to_CU__c FROM opportunity WHERE Id =:oppId LIMIT 1]; newOpp.Referral_Source__c = refSource; newOpp.Agent_Source__c = agentSource; newOpp.Referring_Contact__c = refContact; newOpp.BryteCoreHotLead__c = bCHLPass; newOpp.RecordTypeId = RTID_Referred; newOpp.Phase__c = 'Scrubbed'; //AVOID EMPTY PICKLISTS/STRINGS if(priceRange != ''){newOpp.Price_Range__c = priceRange;} if(areaInterest != ''){newOpp.Areas_of_Interest_city_state__c = areaInterest;} if(agentNotes != ''){newOpp.Notes_for_Agent__c = agentNotes;} if(description != ''){newOpp.Description = description;} if(mortNotes != ''){newOpp.Mortgage_Notes__c = mortNotes;} if(propAddr != ''){newOpp.Closing_Address__c = propAddr;} if(mortStatus != ''){newOpp.Mortgage_Status__c = mortStatus;} if(mortType != ''){newOpp.Type_of_Mortgage__c = mortType;} if(preQual != ''){newOpp.Pre_Qualified_Amount__c = preQualAmount;} newOpp.Send_To_CU__c = sendCuBool; if(reasonNoCU != ''){newOpp.Reason_not_sent_to_CU__c = reasonNoCU;} if(buyOrSell == 'Buy'){newOpp.Pre_Qualified__c = preQualBool;} else{newOpp.Pre_Qualified__c = 'No';} update newOpp; if (updateBoth == 'true'){ Opportunity otherOpp = [SELECT Id,Referral_Source__c, Agent_Source__c,Referring_Contact__c,Price_Range__c,Areas_of_Interest_city_state__c,Notes_for_Agent__c,Description,Mortgage_Notes__c,Closing_Address__c,Property_Street__c,Property_City__c,Mortgage_Status__c,Type_of_Mortgage__c,Pre_Qualified__c,Pre_Qualified_Amount__c,Send_To_CU__c,Reason_not_sent_to_CU__c FROM opportunity WHERE Id =:otherOppId LIMIT 1]; otherOpp.Referral_Source__c = refSource; otherOpp.Agent_Source__c = agentSource; otherOpp.Referring_Contact__c = refContact; otherOpp.BryteCoreHotLead__c = bCHLPass; otherOpp.RecordTypeId = RTID_Referred; otherOpp.Phase__c = 'Scrubbed'; //AVOID EMPTY PICKLISTS/STRINGS if(priceRange != ''){otherOpp.Price_Range__c = priceRange;} if(areaInterest != ''){otherOpp.Areas_of_Interest_city_state__c = areaInterest;} if(agentNotes != ''){otherOpp.Notes_for_Agent__c = agentNotes;} if(description != ''){otherOpp.Description = description;} if(mortNotes != ''){otherOpp.Mortgage_Notes__c = mortNotes;} if(propAddr != ''){otherOpp.Closing_Address__c = propAddr;} if(mortStatus != ''){otherOpp.Mortgage_Status__c = mortStatus;} if(mortType != ''){otherOpp.Type_of_Mortgage__c = mortType;} if(preQual != ''){otherOpp.Pre_Qualified_Amount__c = preQualAmount;} if(reasonNoCU != ''){otherOpp.Reason_not_sent_to_CU__c = reasonNoCU;} //else{newOpp.Reason_not_sent_to_CU__c = 'CU Realty was unable to connect with member';} if(buyOrSell == 'Sell'){newOpp.Pre_Qualified__c = preQualBool;} else{newOpp.Pre_Qualified__c = 'No';} otherOpp.Send_To_CU__c = sendCuBool; update otherOpp; } return 'Success'; } catch(Exception e){ return e.getMessage(); } }
Based on it set the data to test class
All Answers
Based on it set the data to test class
Thank you! That worked. I found a couple errors in the logs by doing that. I thought it was the true/false variable causing the error. I appreciate it!
Jessica