• Addison Melissa
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi there,

Im writing a test class to cover a task trigger.  I have 73% code coverage currently.  The lines of code that i havent written a Test for are below, as im unsure how to write Tests for this.  Im very new to APEX.  Any help is much appreciated.  Many thanks.

 List<Id> OppIds=new List<Id>();
    for(Task t:trigger.new)
    {
        if(t.Status=='Completed')
        {
            if(t.whatId != null && String.valueOf(t.whatId).startsWith('006')==TRUE) //check if the task is associated with an Opp
            {
                OppIds.add(t.whatId);
                //System.debug('In here:' + t.whatid);
            }//if 2
        }//if 1
    }//for
        
    map<id,Opportunity> OpptaskMap = new map<id,Opportunity>([SELECT Id, Situation__c, Forecast_Delivery_Start_Date__c, Forecast_Delivery_End_Date__c, Bypass_Validation_Rule__c, Problem__c, Implication__c, Need_Payoff__c , Involves_Active_Partners__c, Google_Drive_URL__c, StageName, (Select ID From OpportunityLineItems) FROM Opportunity WHERE Id IN :OppIds]);
    
    
    List<OpportunityContactRole> OCR = [select id from OpportunityContactRole where OpportunityId IN :oppIds];
    List<OpportunityPartner> OPartner = [select id from OpportunityPartner where OpportunityId in :oppIds];