• vinod kumar 364
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 4
    Replies
Hi,

I have Problem with code coverage in apex class.

what I'm doing here is I wrote a trigger for convert currency to words in that trigger I used this apex class.

Now I just want to know how I want to write a test class for apex class? before I just wrote a test class for apex trigger for that apex class it is coming 68% of code coverage someone please help me how can I get code coverage for apex class.


Apex trigger 
trigger ConvertCurrencyToWords on I_Invoice__c (before insert, before update) {

    for (I_Invoice__c c: Trigger.new) {
    If(c.State_Code__c!='29'){
    
        if (c.Final_value_IGST__c!= null && c.Final_value_IGST__c>= 0) {
          
            Long n = c.Final_value_IGST__c.longValue();
            string amo = ConvrtCurrencyToWords.english_number(n);
            string amo1 = amo.remove(',');
            c.Amount_in_Words__c = amo1;
        } 
        
    }
    
     If(c.State_Code__c=='29'){
    
        if (c.Final_value_C_SGST__c!= null && c.Final_value_C_SGST__c>= 0) {
          
            Long n = c.Final_value_C_SGST__c.longValue();
            string amo = ConvrtCurrencyToWords.english_number(n);
            string amo1 = amo.remove(',');
            c.Amount_in_Words__c = amo1;
        } /*else {
            c.Amount_in_Words__c = null;
        } */
    }
    
    
   }
}

Apex class (which I used in apex trigger now I need code coverage for this apex class)
 
public with sharing class ConvrtCurrencyToWords { 
      
        static String[] to_19 = new string[]{ 'zero', 'One',  'Two', 'Three', 'Four',  'Five',  'Six', 'Seven',
                                              'Eight', 'Nine', 'Ten',  'Eleven', 'Twelve', 'Thirteen',  
                                              'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen' }; 
        static String[] tens = new string[]{ 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'}; 
      
        static string[] denom = new string[]{ '', 
                                             'Thousand',   'Million',     'Billion',    'trillion',    'quadrillion',  
                                             'quintillion', 's!xtillion',   'septillion',  'octillion',   'nonillion',  
                                             'decillion',  'undecillion',   'duodecillion', 'tredecillion',  'quattuordecillion',  
                                             's!xdecillion', 'septendecillion', 'octodecillion', 'novemdecillion', 'vigintillion' }; 
    // convert a value < 100 to English.   
   public static string convert_nn(integer val) { 
             if (val < 20) 
        return to_19[val]; 
      if (val == 100) 
          return 'One Hundred'; 
      for (integer v = 0; v < tens.size(); v++) { 
        String dcap = tens[v]; 
        integer dval = 20 + 10 * v; 
        if (dval + 10 > val) { 
          if (Math.Mod(val,10) != 0) 
            return dcap + ' ' + to_19[Math.Mod(val,10)]; 
          return dcap; 
        }     
      } 
      return 'Should never get here, less than 100 failure'; 
    } 
    // convert a value < 1000 to english, special cased because it is the level that kicks   
    // off the < 100 special case. The rest are more general. This also allows you to  
    // get strings in the form of "forty-five hundred" if called directly.  
    public static String convert_nnn(integer val) { 
      string word = ''; 
      integer rem = val / 100; 
      integer mod = Math.mod(val,100); 
      if (rem > 0) { 
        word = to_19[rem] + ' Hundred and'; 
        if (mod > 0) { 
          word += ' '; 
        } 
      } 
      if (mod > 0) { 
        word += convert_nn(mod); 
      } 
      return word; 
    } 
    public static String english_number(long val) { 
      if (val < 100) { 
        return convert_nn(val.intValue()); 
      } 
      if (val < 1000) { 
        return convert_nnn(val.intValue()); 
      } 
      for (integer v = 0; v < denom.size(); v++) { 
        integer didx = v - 1; 
        integer dval = (integer)Math.pow(1000, v); 
        if (dval > val) { 
          integer mod = (integer)Math.pow(1000, didx); 
          integer l = (integer) val / mod; 
          integer r = (integer) val - (l * mod); 
          String ret = convert_nnn(l) + ' ' + denom[didx]; 
          if (r > 0) { 
            ret += ', ' + english_number(r); 
          } 
          return ret; 
        } 
      } 
      return 'Should never get here, bottomed out in english_number'; 
    } 
  }
Test class :
 
@istest
public class TestConvertCurrencyToWords {

  static testMethod void test() {
    
       Account acc=new Account();
       acc.Name='jsjsdd';
       acc.Industry__c='Energy';
       acc.Activity__c='End User';
       Acc.BillingCountry='India';
       Acc.BillingState='Sikkim';
       Acc.BillingCity='dsad';            
       Acc.BillingStreet='dsaf';             
       Acc.BillingPostalCode='453658';         
        
       Insert acc;
     
        I_Invoice__c co = new I_Invoice__c();
         co.Buyers_Order_No__c='blah';
         //co.Buyers_Order_Date__c='12-02-2018';
         co.Customer_GSTIN__c='14535HGFNHG423';
         co.Amount_in_Words__c='';
         co.State_Code__c='07';
         co.Despatch_Through__c='by hand';
         co.Part_Numbers__c=20;
         co.CGST__c=18;
         co.SGST__c=12;
         co.IGST__c=15;
         co.Freight_Insurance__c=50;
         co.Insurance__c=40;
         co.Packing_and_Forwarding_Charges__c=200;
         co.Account__c=acc.id;
         co.Autonum__c='4';
         co.Billing_Country__c=acc.BillingCountry;
         co.Billing_State_Province__c=acc.BillingState;
         co.Billing_City__c= Acc.BillingCity;
         co.Billing_Street__c= Acc.BillingStreet;
         co.Billing_Zip_Postal_Code__c= Acc.BillingPostalCode;
         co.Account_Name__c=Acc.Name;
         co.Freight_Insurance__c=200;
         co.Insurance__c=200;
         co.Amount_In_Words__c='DASDASD';
         co.Place_of_Supply__c='sada';
         co.Same_Address__c=true;
        insert co;
        co.Invoice_Generated__c=true;
        update co;
  }   

 static testMethod void test1() {
    
       Account acc=new Account();
       acc.Name='sdfsdf';
       acc.Industry__c='Energy';
       acc.Activity__c='End User';
       Acc.BillingCountry='India';
       Acc.BillingState='Sikkim';
       Acc.BillingCity='dsad';            
       Acc.BillingStreet='dsaf';             
       Acc.BillingPostalCode='453658';         
        
       Insert acc;
     
        I_Invoice__c co = new I_Invoice__c();
         co.Buyers_Order_No__c='blah';
         //co.Buyers_Order_Date__c='12-02-2018';
         co.Customer_GSTIN__c='14535HGFNHG423';
         co.State_Code__c='29';
         co.Amount_in_Words__c=null;
         
         co.Despatch_Through__c='by hand';
         co.Part_Numbers__c=20;
         co.CGST__c=18;
         co.SGST__c=12;
         co.IGST__c=15;
         co.Freight_Insurance__c=200;
         co.Insurance__c=200;
         co.Packing_and_Forwarding_Charges__c=200;
         co.Account__c=acc.id;
         co.Autonum__c='4';
         co.Billing_Country__c=acc.BillingCountry;
         co.Billing_State_Province__c=acc.BillingState;
         co.Billing_City__c= Acc.BillingCity;
         co.Billing_Street__c= Acc.BillingStreet;
         co.Billing_Zip_Postal_Code__c= Acc.BillingPostalCode;
         co.Account_Name__c=Acc.Name;
         co.Freight_Insurance__c=200;
         co.Insurance__c=200;
         co.Amount_In_Words__c='DASDASD';
         co.Place_of_Supply__c='sada';
         co.Same_Address__c=true;
        insert co;
        co.Invoice_Generated__c=true;
        update co;
  }
   
    
    
}



 
User-added image
please look at my above Image it shows how my page is breaking on my Visualforce PDF page, Here I want my entire 3rd row should go to next page without breaking in the middle.

So please find the code related to above concern:
<table style="font-size:80%;*page-break-inside:avoid*" border="1px" cellpadding="0" cellspacing="0" height="100%" width="100%​">

 
I tried several times to get the code coverage for the below test class now I need someone's help to get code coverage for red color coding in the Image How can I ???
Here the below image shows the code coverage.​

code coverage problem

My trigger
trigger customsolinsert on Price_Study__c (after update, after insert) {
// Find the existing (0 or 1) Custom_solution__c that reference Price_Study__c 
    Map<Id, Custom_solution__c> m = new Map<Id, Custom_solution__c>();
   list<Custom_solution__c> oblist=[ select id, Price_Study__c from Custom_solution__c where Price_Study__c in :Trigger.newMap.keySet() ];
    for (Custom_solution__c ob : oblist) {
        m.put(ob.Price_Study__c, ob);
    }  
// Insert or update the Custom_solution__c
List<Custom_solution__c> csol= new List<Custom_solution__c>();

for (Price_Study__c b : trigger.new) {
    // Get record to update
    Custom_solution__c ob = m.get(b.id);

  if(b.Analysis_Done_By__c<>Null){
 if (ob == null) {
        // If no record to update, add a record to be inserted
        ob = new Custom_solution__c(Price_Study__c = b.id);
    }
         ob.Price_Study__c=b.Id;       
         ob.Country__c=b.Country_of_Treatment__c;
         ob.Who_Deals__c=b.Analysis_Done_By__c;
         ob.Customer__c=b.Account_Name__c;
         ob.Product_line__c=b.Product_line__c;
         ob.Function_Focus__c=b.Function_Focus__c;
         ob.Comments__c=b.Generic_Comments__c;
         ob.Nbrs_Post__c=b.Nbrs_Post__c;
         ob.Series_Row_nbr__c=b.Series_Row_nbr__c;

    csol.add(ob);
   }
} 
upsert csol;

Test class
@istest(isParallel=true)
  public class Testcustomsolinsert{
  @istest Static void Testcustomsol1(){

    Profile prof = [select id from profile where name='system Administrator'];
    List<User> lstUser = [Select u.Profile.Name, u.ProfileId, u.IsActive, u.Id From User u Where IsActive = true AND Profile.Name = 'System Administrator'];
    system.runAs(lstUser[0]){


   Account acc=new account(Name='NicoTestacc',BillingCountry='India');
    insert acc;

    Opportunity op1= new opportunity(Name='NicoTestOpp',CloseDate=date.today(),StageName='Qualification',Product_Type__c='DPI',Accountid=acc.Id);
    insert op1;
    System.assertEquals(op1.name,'NicoTestOpp');
    Price_Study__c ps=new Price_Study__c(Country_of_Treatment__c='India',Series_Row_nbr__c=3,
                                   Nbrs_Post__c=2,Analysis_Done_By__c=op1.OwnerId,
                                   Generic_Comments__c='asdfds',Function_Focus__c='sdad',
                                   Product_line__c='CMM');

    Insert Ps;

        Map<Id, Custom_solution__c> m = new Map<Id, Custom_solution__c>();             


        Custom_solution__c cs1=new Custom_solution__c(Price_Study__c=PS.Id,Country__c=Ps.Country_of_Treatment__c);

        Insert cs1;

        delete cs1;

     Custom_solution__c cs=new Custom_solution__c();


          cs.Price_Study__c=ps.Id;
          cs.Country__c=Ps.Country_of_Treatment__c;
          cs.Who_Deals__c=ps.Analysis_Done_By__c;
          cs.Customer__c=ps.Account_Name__c;
          cs.Product_line__c='Cmm';
          cs.Function_Focus__c=ps.Function_Focus__c;
          cs.Comments__c=ps.Generic_Comments__c;
          cs.Nbrs_Post__c=ps.Nbrs_Post__c;
          cs.Series_Row_nbr__c=ps.Series_Row_nbr__c;

  Insert cs;

        cs.Function_Focus__c=ps.Function_Focus__c;

  Update cs;
    }      
}
  }



 
I have my triggerhandler for Inventory, what I am doing in that triggerhandler is storing aggregate results here and querying Quantity's sum From Inventory I'm putting into Items.Quantity utilised.
Hereafter onAfterInsert and onAfterUpdate is working fine,
but OnAfterDelete is not working.


public class InventoryObjectTriggerHandler {

    private boolean m_isExecuting = false;
    private integer BatchSize = 0;
    
   

   Map<Id,Items__c> UpdateMap = new Map<Id,Items__c>();
    Set<Id> InvenIds = new Set<Id>();

    
    public InventoryObjectTriggerHandler(boolean isExecuting, integer size){
        m_isExecuting = isExecuting;
        BatchSize = size;
    }
        
    public void OnBeforeInsert(List<Inventory__c> newInventory){
        
    }
     public void OnAfterInsert(List<Inventory__c> newInventory){
     
      
       for(Inventory__c record : newInventory) {
            if (record.Items__c != null){
                InvenIds.add(record.Items__c);
            }
        }
        
        List<AggregateResult> arlist = [SELECT Items__c , SUM(Quantity__c)sum FROM Inventory__c WHERE Items__c IN : InvenIds GROUP BY Items__c];
        
        for(AggregateResult ar : arlist){
            Items__c q=new Items__c(Id=(Id)ar.get('Items__c'), Quantity_Utilised__c=(Decimal)ar.get('sum'));
            UpdateMap.put(q.id,q);
        }
        
        if(!UpdateMap.isEmpty()){
           update UpdateMap.values();
         }
 
     }

    public void OnBeforeUpdate(Map<ID, Inventory__c> oldInventory, List<Inventory__c> updatedInventory, Map<ID, Inventory__c> InventoryMap){
        
    }
    
    public void OnAfterUpdate(List<Inventory__c> oldInventory, List<Inventory__c> updatedInventory,Map<ID, Inventory__c> oldInventoryMap,Map<ID, Inventory__c> InventoryMap){
        
      
             for(Inventory__c record : updatedInventory) {
            if (record.Items__c != null){
                InvenIds.add(record.Items__c);
            }
        }
        
        List<AggregateResult> arlist = [SELECT Items__c , SUM(Quantity__c)sumMax FROM Inventory__c WHERE Items__c IN : InvenIds GROUP BY Items__c];
        
        for(AggregateResult ar : arlist){
            Items__c q=new Items__c(Id=(Id)ar.get('Items__c'), Quantity_Utilised__c=(Decimal)ar.get('sumMax'));
            UpdateMap.put(q.id,q);
        }
        
        if(!UpdateMap.isEmpty()){
           update UpdateMap.values();
        }
 
        }        
              
    public void OnBeforeDelete(List<Inventory__c> qliToDelete, Map<ID, Inventory__c> quoteLineItemMap){
    
    
    }
    
    public void OnAfterDelete(List<Inventory__c> deletedInv, Map<ID, Inventory__c> InventoryMap){
      
       
        for(Inventory__c record : deletedInv) {
            if (record.Items__c != null){
                InvenIds.add(record.Items__c);
            }
        }
        system.debug(InvenIds);
        List<AggregateResult> arlist = [SELECT Items__c , SUM(Quantity__c)sumMax FROM Inventory__c WHERE Items__c IN : InvenIds GROUP BY Items__c];
         system.debug(arlist);
        for(AggregateResult ar : arlist){
            Items__c q=new Items__c(Id=(Id)ar.get('Items__c'), Quantity_Utilised__c=0);
           system.debug(ar);
            UpdateMap.put(q.id,q);
        }
        
       
        system.debug(UpdateMap);
        if(!UpdateMap.isEmpty()){
           update UpdateMap.values();
        }
   
     
    }
    public void OnUndelete(List<Inventory__c> restoredQuoteLineItem){

    }

        }

 


Enter code here
User-added image
User-added image
VF Page:


<table width="500px" align="center" cellpadding="2" cellspacing="2">
           <tr>
                    <td colspan="4" align="center"><font size="3"><b>Upload Documents</b></font><br />
                    <br />
                    <br /></td>
                </tr>
         <tr><td> </td>
                <td>   <apex:inputFile id="fileToUpload" value="{!fileBody}" filename="{!fileName}" /> </td>
                <td><apex:outputText value="{!filename}"></apex:outputtext></td>
          <td> <apex:commandButton value="Upload Attachment" action="{!uploadattachment1}"/>  </td>  
                </tr>

              <tr>
               <td> </td>
             <td>  <apex:inputFile id="fileToUpload2" value="{!fileBody2}" filename="{!fileName2}" />  </td>
              <td><apex:outputText value="{!filename2}"></apex:outputtext></td>
           <td> <apex:commandButton value="Upload Attachment" action="{!uploadattachment2}"/>  </td>      
                </tr>
                <tr>
                <td> </td>
             <td>   <apex:inputFile id="fileToUpload3" value="{!fileBody3}" filename="{!fileName3}" /> </td>
              <td><apex:outputText value="{!filename3}"></apex:outputtext></td>
           <td> <apex:commandButton value="Upload Attachment" action="{!uploadattachment3}"/>  </td>    
                </tr> 
            </table>  





APEX Code:




 public void uploadattachment1() 
      {
       if(fileBody != null && fileName != null)
        {
          Attachment myAttachment1  = new Attachment();
          myAttachment1.Body = fileBody;
          myAttachment1.Name = fileName;
          myAttachment1.ParentId = cid;        
           insert myAttachment1;
        }
      }

 I need an option in VF page to help me choose a file from salesforce and external computer.
I have one Custom Email temple there I am currently uploading My Computer Documents,here we already uploaded some files into salesforce, How Can Send Salesforce files Attaching with Custom Email Template, (I need salesforce files selecting option in that custom Email Template) Moreover what i need the below image shows the option I want that option in my Custom Email template, How Can I do This...????


User-added image
 
Hi,

I have Problem with code coverage in apex class.

what I'm doing here is I wrote a trigger for convert currency to words in that trigger I used this apex class.

Now I just want to know how I want to write a test class for apex class? before I just wrote a test class for apex trigger for that apex class it is coming 68% of code coverage someone please help me how can I get code coverage for apex class.


Apex trigger 
trigger ConvertCurrencyToWords on I_Invoice__c (before insert, before update) {

    for (I_Invoice__c c: Trigger.new) {
    If(c.State_Code__c!='29'){
    
        if (c.Final_value_IGST__c!= null && c.Final_value_IGST__c>= 0) {
          
            Long n = c.Final_value_IGST__c.longValue();
            string amo = ConvrtCurrencyToWords.english_number(n);
            string amo1 = amo.remove(',');
            c.Amount_in_Words__c = amo1;
        } 
        
    }
    
     If(c.State_Code__c=='29'){
    
        if (c.Final_value_C_SGST__c!= null && c.Final_value_C_SGST__c>= 0) {
          
            Long n = c.Final_value_C_SGST__c.longValue();
            string amo = ConvrtCurrencyToWords.english_number(n);
            string amo1 = amo.remove(',');
            c.Amount_in_Words__c = amo1;
        } /*else {
            c.Amount_in_Words__c = null;
        } */
    }
    
    
   }
}

Apex class (which I used in apex trigger now I need code coverage for this apex class)
 
public with sharing class ConvrtCurrencyToWords { 
      
        static String[] to_19 = new string[]{ 'zero', 'One',  'Two', 'Three', 'Four',  'Five',  'Six', 'Seven',
                                              'Eight', 'Nine', 'Ten',  'Eleven', 'Twelve', 'Thirteen',  
                                              'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen' }; 
        static String[] tens = new string[]{ 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'}; 
      
        static string[] denom = new string[]{ '', 
                                             'Thousand',   'Million',     'Billion',    'trillion',    'quadrillion',  
                                             'quintillion', 's!xtillion',   'septillion',  'octillion',   'nonillion',  
                                             'decillion',  'undecillion',   'duodecillion', 'tredecillion',  'quattuordecillion',  
                                             's!xdecillion', 'septendecillion', 'octodecillion', 'novemdecillion', 'vigintillion' }; 
    // convert a value < 100 to English.   
   public static string convert_nn(integer val) { 
             if (val < 20) 
        return to_19[val]; 
      if (val == 100) 
          return 'One Hundred'; 
      for (integer v = 0; v < tens.size(); v++) { 
        String dcap = tens[v]; 
        integer dval = 20 + 10 * v; 
        if (dval + 10 > val) { 
          if (Math.Mod(val,10) != 0) 
            return dcap + ' ' + to_19[Math.Mod(val,10)]; 
          return dcap; 
        }     
      } 
      return 'Should never get here, less than 100 failure'; 
    } 
    // convert a value < 1000 to english, special cased because it is the level that kicks   
    // off the < 100 special case. The rest are more general. This also allows you to  
    // get strings in the form of "forty-five hundred" if called directly.  
    public static String convert_nnn(integer val) { 
      string word = ''; 
      integer rem = val / 100; 
      integer mod = Math.mod(val,100); 
      if (rem > 0) { 
        word = to_19[rem] + ' Hundred and'; 
        if (mod > 0) { 
          word += ' '; 
        } 
      } 
      if (mod > 0) { 
        word += convert_nn(mod); 
      } 
      return word; 
    } 
    public static String english_number(long val) { 
      if (val < 100) { 
        return convert_nn(val.intValue()); 
      } 
      if (val < 1000) { 
        return convert_nnn(val.intValue()); 
      } 
      for (integer v = 0; v < denom.size(); v++) { 
        integer didx = v - 1; 
        integer dval = (integer)Math.pow(1000, v); 
        if (dval > val) { 
          integer mod = (integer)Math.pow(1000, didx); 
          integer l = (integer) val / mod; 
          integer r = (integer) val - (l * mod); 
          String ret = convert_nnn(l) + ' ' + denom[didx]; 
          if (r > 0) { 
            ret += ', ' + english_number(r); 
          } 
          return ret; 
        } 
      } 
      return 'Should never get here, bottomed out in english_number'; 
    } 
  }
Test class :
 
@istest
public class TestConvertCurrencyToWords {

  static testMethod void test() {
    
       Account acc=new Account();
       acc.Name='jsjsdd';
       acc.Industry__c='Energy';
       acc.Activity__c='End User';
       Acc.BillingCountry='India';
       Acc.BillingState='Sikkim';
       Acc.BillingCity='dsad';            
       Acc.BillingStreet='dsaf';             
       Acc.BillingPostalCode='453658';         
        
       Insert acc;
     
        I_Invoice__c co = new I_Invoice__c();
         co.Buyers_Order_No__c='blah';
         //co.Buyers_Order_Date__c='12-02-2018';
         co.Customer_GSTIN__c='14535HGFNHG423';
         co.Amount_in_Words__c='';
         co.State_Code__c='07';
         co.Despatch_Through__c='by hand';
         co.Part_Numbers__c=20;
         co.CGST__c=18;
         co.SGST__c=12;
         co.IGST__c=15;
         co.Freight_Insurance__c=50;
         co.Insurance__c=40;
         co.Packing_and_Forwarding_Charges__c=200;
         co.Account__c=acc.id;
         co.Autonum__c='4';
         co.Billing_Country__c=acc.BillingCountry;
         co.Billing_State_Province__c=acc.BillingState;
         co.Billing_City__c= Acc.BillingCity;
         co.Billing_Street__c= Acc.BillingStreet;
         co.Billing_Zip_Postal_Code__c= Acc.BillingPostalCode;
         co.Account_Name__c=Acc.Name;
         co.Freight_Insurance__c=200;
         co.Insurance__c=200;
         co.Amount_In_Words__c='DASDASD';
         co.Place_of_Supply__c='sada';
         co.Same_Address__c=true;
        insert co;
        co.Invoice_Generated__c=true;
        update co;
  }   

 static testMethod void test1() {
    
       Account acc=new Account();
       acc.Name='sdfsdf';
       acc.Industry__c='Energy';
       acc.Activity__c='End User';
       Acc.BillingCountry='India';
       Acc.BillingState='Sikkim';
       Acc.BillingCity='dsad';            
       Acc.BillingStreet='dsaf';             
       Acc.BillingPostalCode='453658';         
        
       Insert acc;
     
        I_Invoice__c co = new I_Invoice__c();
         co.Buyers_Order_No__c='blah';
         //co.Buyers_Order_Date__c='12-02-2018';
         co.Customer_GSTIN__c='14535HGFNHG423';
         co.State_Code__c='29';
         co.Amount_in_Words__c=null;
         
         co.Despatch_Through__c='by hand';
         co.Part_Numbers__c=20;
         co.CGST__c=18;
         co.SGST__c=12;
         co.IGST__c=15;
         co.Freight_Insurance__c=200;
         co.Insurance__c=200;
         co.Packing_and_Forwarding_Charges__c=200;
         co.Account__c=acc.id;
         co.Autonum__c='4';
         co.Billing_Country__c=acc.BillingCountry;
         co.Billing_State_Province__c=acc.BillingState;
         co.Billing_City__c= Acc.BillingCity;
         co.Billing_Street__c= Acc.BillingStreet;
         co.Billing_Zip_Postal_Code__c= Acc.BillingPostalCode;
         co.Account_Name__c=Acc.Name;
         co.Freight_Insurance__c=200;
         co.Insurance__c=200;
         co.Amount_In_Words__c='DASDASD';
         co.Place_of_Supply__c='sada';
         co.Same_Address__c=true;
        insert co;
        co.Invoice_Generated__c=true;
        update co;
  }
   
    
    
}



 
User-added image
please look at my above Image it shows how my page is breaking on my Visualforce PDF page, Here I want my entire 3rd row should go to next page without breaking in the middle.

So please find the code related to above concern:
<table style="font-size:80%;*page-break-inside:avoid*" border="1px" cellpadding="0" cellspacing="0" height="100%" width="100%​">

 
I tried several times to get the code coverage for the below test class now I need someone's help to get code coverage for red color coding in the Image How can I ???
Here the below image shows the code coverage.​

code coverage problem

My trigger
trigger customsolinsert on Price_Study__c (after update, after insert) {
// Find the existing (0 or 1) Custom_solution__c that reference Price_Study__c 
    Map<Id, Custom_solution__c> m = new Map<Id, Custom_solution__c>();
   list<Custom_solution__c> oblist=[ select id, Price_Study__c from Custom_solution__c where Price_Study__c in :Trigger.newMap.keySet() ];
    for (Custom_solution__c ob : oblist) {
        m.put(ob.Price_Study__c, ob);
    }  
// Insert or update the Custom_solution__c
List<Custom_solution__c> csol= new List<Custom_solution__c>();

for (Price_Study__c b : trigger.new) {
    // Get record to update
    Custom_solution__c ob = m.get(b.id);

  if(b.Analysis_Done_By__c<>Null){
 if (ob == null) {
        // If no record to update, add a record to be inserted
        ob = new Custom_solution__c(Price_Study__c = b.id);
    }
         ob.Price_Study__c=b.Id;       
         ob.Country__c=b.Country_of_Treatment__c;
         ob.Who_Deals__c=b.Analysis_Done_By__c;
         ob.Customer__c=b.Account_Name__c;
         ob.Product_line__c=b.Product_line__c;
         ob.Function_Focus__c=b.Function_Focus__c;
         ob.Comments__c=b.Generic_Comments__c;
         ob.Nbrs_Post__c=b.Nbrs_Post__c;
         ob.Series_Row_nbr__c=b.Series_Row_nbr__c;

    csol.add(ob);
   }
} 
upsert csol;

Test class
@istest(isParallel=true)
  public class Testcustomsolinsert{
  @istest Static void Testcustomsol1(){

    Profile prof = [select id from profile where name='system Administrator'];
    List<User> lstUser = [Select u.Profile.Name, u.ProfileId, u.IsActive, u.Id From User u Where IsActive = true AND Profile.Name = 'System Administrator'];
    system.runAs(lstUser[0]){


   Account acc=new account(Name='NicoTestacc',BillingCountry='India');
    insert acc;

    Opportunity op1= new opportunity(Name='NicoTestOpp',CloseDate=date.today(),StageName='Qualification',Product_Type__c='DPI',Accountid=acc.Id);
    insert op1;
    System.assertEquals(op1.name,'NicoTestOpp');
    Price_Study__c ps=new Price_Study__c(Country_of_Treatment__c='India',Series_Row_nbr__c=3,
                                   Nbrs_Post__c=2,Analysis_Done_By__c=op1.OwnerId,
                                   Generic_Comments__c='asdfds',Function_Focus__c='sdad',
                                   Product_line__c='CMM');

    Insert Ps;

        Map<Id, Custom_solution__c> m = new Map<Id, Custom_solution__c>();             


        Custom_solution__c cs1=new Custom_solution__c(Price_Study__c=PS.Id,Country__c=Ps.Country_of_Treatment__c);

        Insert cs1;

        delete cs1;

     Custom_solution__c cs=new Custom_solution__c();


          cs.Price_Study__c=ps.Id;
          cs.Country__c=Ps.Country_of_Treatment__c;
          cs.Who_Deals__c=ps.Analysis_Done_By__c;
          cs.Customer__c=ps.Account_Name__c;
          cs.Product_line__c='Cmm';
          cs.Function_Focus__c=ps.Function_Focus__c;
          cs.Comments__c=ps.Generic_Comments__c;
          cs.Nbrs_Post__c=ps.Nbrs_Post__c;
          cs.Series_Row_nbr__c=ps.Series_Row_nbr__c;

  Insert cs;

        cs.Function_Focus__c=ps.Function_Focus__c;

  Update cs;
    }      
}
  }