function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dharmik thummardharmik thummar 

How i get code coverage for this code

if(!mm1.isEmpty()){
                    For(Milestone1_Task__c mm1u: mm1){
                        mm1u.Task_Stage__c = triggerNew[0].Determine_Business_Name__c;
                        if(triggerNew[0].Determine_Business_Name__c == 'Completed'){
                            mm1u.Complete__c = true;
                            mm1u.Complete_Date__c = system.Today();
                        }
                    }
                    mtList.addAll( mm1);
        
                }

 
Kirti Deshpande 13Kirti Deshpande 13
Hi Dharmik,

Assuming that you are trying insert/update Milestone1_Task__c object, test class goes as below
@isTest
public with sharing class TestClass
{
    static testMethod void TestMethod() 
    {
        List<Milestone1_Task__c > milestList = new List<Milestone1_Task__c >();
        Milestone1_Task__c milestoneObj =  new milestone1_Task__c();
        milestoneObj.Determine_Business_Name__c = 'Completed';
        milestList.add(milestoneObj)
        insert milestList;
    }

Thanks,
KD​