You need to sign in to do that
Don't have an account?
sfdc007
Trigger test coverage help needed
Hi,
I have a trigger for which i am not able to cover certain methods in it , I have a test class for it
I need help to cover those methods
Kindly help me pls
Thanks in Advance
I have a trigger for which i am not able to cover certain methods in it , I have a test class for it
I need help to cover those methods
Kindly help me pls
Methods to cover in my trigger if(trigger.isBefore) { if (trigger.isDelete) { map<Id,List<Team_Form_Member__c >> TeammemberMap = new map<Id,List<Team_Form_Member__c>>(); list <Id> RemoveLst = new list <Id>(); list <Id> RemoveuserLst = new list <Id>(); for(Integer i=0;i<trigger.old.size();i++) { RemoveLst.add(trigger.Old[i].Id); RemoveuserLst.add(trigger.Old[i].Team_Member__c); removeId = trigger.Old[i].Id; if(trigger.Old[i].GPS_Team_Form_Role__c <> null) { gpsteamrole.add(trigger.Old[i].UserName__c); } } if(!RemoveLst.isEmpty()) { list<Id> EpscriptId = new list <Id>(); list<Id> EpTeamformId = new list <Id>(); Id EPscriptIds; list<Team_Form_Member__c> EPTeammember = [select Team_Form__c,Id,name,Team_Member__c,Team_Form__r.Engagement_Script__c,Team_Form__r.Engagement_Team__r.Initial__c from Team_Form_Member__c where Id in :RemoveLst and Team_Role__c != :EP_Utilities.getEPLabel('TFM_Role_SharingAccess')]; for(Team_Form_Member__c TeamMember: EPTeammember) { EPscriptIds = TeamMember.Team_Form__r.Engagement_Script__c; EpscriptId.add(TeamMember.Team_Form__r.Engagement_Script__c); EpTeamformId.add(TeamMember.Team_Form__c); EpTeamformIntitial.add(TeamMember.Team_Form__r.Engagement_Team__r.Initial__c); } List <Engagement_Script__c> EPscript = [select Id,AccountManager__c,REQUESTOR__c from Engagement_Script__c where Id in : EpscriptId]; List <Team_Form_Member__c> EPTeammemberLst = [select GPS_Team_Form_Role__c,Team_Member__c,PRM_Portal_URL_ESID__c, PRM_Portal_URL_OPPTYID__c, UserName__c,id,Team_Role__c,OpportunityName__c,AccountName__c,EngagedTeam__c,Team_Form__r.Team_initials__c,Team_Form__c,EPScriptOpptyLink__c,NASP_Name__c,EPScriptLink__c,Team_Form__r.BidName__c,Team_Form__r.Engagement_Script__r.Name from Team_Form_Member__c where Team_Form__c in :EpTeamformId and Status__c =:'Active']; list <Id> userlst = new list <Id>(); for(Team_Form_Member__c TFM: EPTeammemberLst) { if(TFM.Team_Form__c <> null) { List <Team_Form_Member__c> lstTFM = new List <Team_Form_Member__c>(); if(TeammemberMap.get(TFM.Team_Form__c)!=null) lstTFM = TeammemberMap.get(TFM.Team_Form__c); lstTFM.add(TFM); TeammemberMap.put(TFM.Team_Form__c,lstTFM); } if(TFM.GPS_Team_Form_Role__c <> null) RemoveuserLst.add(TFM.Team_Member__c); } if(!EPTeammember.isempty() && gpsteamrole.size()==0) { userlst = EPEmailReceiptList.EPEmailSuperUserLst(EPscript); } else userlst.addall(RemoveuserLst); system.debug('userlst-->'+userlst); if(!userlst.isEmpty()&& Label.EP_Email_ON_OFF =='ON') { for(Id TFId : TeammemberMap.KeySet()) { //EP_EmailComponent obj = new EP_EmailComponent(); //obj.SendEmailsWithoutTemplate(userlst,EPTeammemberLst,'Add'); system.debug('EpTeamformIntitial==>'+EpTeamformIntitial); if(!EpTeamformIntitial.contains('EMEA SaSu')) EP_EmailComponent.SendEmailsWithoutTemplate(userlst,TFId,'Removed',EPscriptIds,removeId,gpsteamrole); } } } } }
MY TEST CLASS : @Istest(seeAllData=true) public class Team_Form_Member_AfterInsDel_Test { Public static testmethod void TestMethod1() { string strUsr; User usr = GPSTestUtilities.createStandardUser(strUsr); System.runAs(usr) { skipingHelper.SkippThemAll(); Account acct = GPSTestUtilities.createTestAccount(); Opportunity oppty1 = GPSTestUtilities.createTestOpportunity(acct.Id); Team_Group_Member__c TGM = GPSTestUtilities.createTeamGroupMember(); Engagement_Script__c ES = GPSTestUtilities.createEngagementScript(acct.Id,oppty1.Id); test.startTest(); Team_Form__c TF = GPSTestUtilities.createTeamForm(ES.Id); Team_Form_Member__c TfMember = GPSTestUtilities.createTeamFormMember(TF.Id); GPS_PremiSys_Quote__c gpsquote = new GPS_PremiSys_Quote__c(); gpsquote.Engagement_Script_Id__c = ES.Id; gpsquote.GPSTeamForm__c = TF.id; gpsquote.Quote_ID__c = 'Testsss'; insert gpsquote; system.debug('TF::'+TF); TF.Status__c ='Released to Sales'; TF.Status_Comments__c = 'rejtest'; update TF; system.debug('TF::'+TF); TF.Status__c = 'Quote uploaded'; TF.Status_Comments__c = 'tesaaaat'; update TF; test.stopTest(); TF.Status__c = 'Won'; TF.Status_Comments__c = 'tesaaaaqq1t'; update TF; system.debug('TF::'+TF); TF.Status__c = 'Closed Lost'; TF.Status_Comments__c = 'te121ast'; update TF; } } }Kindly help me pls
Thanks in Advance
i am doing both insert and update in my test class , but insert part alone gets covered and the update part is not getting covered , not sure whats the issue