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
shweta raghav 13shweta raghav 13 

how to create test class

else{
                                    integer k = 0;
                                    for(Opportunity_Splits__c s :oSplit){
                                        if(k == 0){
                                            s.Practice__c= pract;
                                            s.Percent__c= 100;
                                            oppspiltUpdatelist.add(s);
                                            k++;
                                        }else{
                                            oppspiltdeletelist.add(s);
                                        }
                                    }
                                }
                            }else{
                                if(oSplit.size() == 1){
                                    for(Opportunity_Splits__c s :oSplit){
                                        if(oldCount == 0){
                                            s.Practice__c= pract;
                                            s.Percent__c= 50;
                                            oppspiltUpdatelist.add(s);
                                            oldCount++;
                                        }else{
                                            Opportunity_Splits__c op =new Opportunity_Splits__c();
                                            op.Practice__c= pract;
                                            op.Percent__c= 50;
                                            op.Opportunity__c= opp.id;
                                            oppspiltNewlist.add(op);
                                        }
                                    }
                                }else{                                
                                    if(oldValue == 0){
                                        oSplit[0].Practice__c= pract;
                                        oSplit[0].Percent__c= 50;
                                        oppspiltUpdatelist.add(oSplit[0]);
                                        oldIds.add(oSplit[0].id);
                                        oldValue++;
                                    }else if(oldValue == 1){
                                        oSplit[1].Practice__c= pract;
                                        oSplit[1].Percent__c= 50;
                                        oppspiltUpdatelist.add(oSplit[1]);
                                        oldIds.add(oSplit[1].id);
                                        oldValue++;
                                        System.debug('test ++ oSplit '+oSplit.size() +' , oldValue '+oldValue+' , oldIds '+oldIds);
                                        if(oSplit.size() >2){
                                            for(Opportunity_Splits__c s :oSplit){
                                                if(!oldIds.Contains(s.id))
                                                    oppspiltdeletelist.add(s);
                                            }
                                        } 
                                    }                                    
                                }
                            }
                        
                        }else{                        
                            Opportunity_Splits__c ONew=new Opportunity_Splits__c();
                            ONew.Practice__c= pract;
                            ONew.Percent__c= 100;
                            ONew.Opportunity__c= opp.id;
                            oppspiltNewlist.add(ONew);
                        }
                    }
                }
            }
        }        
    }
    
    if(!oppspiltdeletelist.isEmpty())
        delete oppspiltdeletelist;  
        
    if(!oppspiltUpdatelist.isEmpty())
        update oppspiltUpdatelist;
    
    if(!oppspiltNewlist.isEmpty())
        insert oppspiltNewlist;    
        
}
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi shweta raghav,

Do You got a chance to check the Test generator app from App Exchange please check the below link   I hope it will be helpful.

Please mark it as best answer if the information is informative.

Best Regards
Rahul Kumar