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
Soundar Rajan PonpandiSoundar Rajan Ponpandi 

Test class code coverage issue for simple apex class

Hi I covered a test class for 62%, Can anyone please explain what is the issue on this ??

Apex class
 
/*
Description : Generate PDF in Sales order Details Page.
*/


public with sharing class GD_SalesOrderPrintableView {
    
    public string so_Id = apexpages.currentpage().getparameters().get('id');
    public List<GD_Order_Line_Item__c> accList{get;set;}
    public List<GD_Address__c> addList{get;set;}
    
    public GD_SalesOrderPrintableView (ApexPages.StandardController controller){
        accList = [select id,name ,GD_Unit_Price__c,GD_Total_Amount_Formula__c, GD_Quantity__c,GD_Item__r.GD_Item_Code__c, GD_Vat__c, GD_Discount__c,GD_Retail_Price__c from GD_Order_Line_Item__c where GD_Sales_Order__c =: so_Id];
        GD_Order__c so = [select id,name,GD_Account__c from GD_Order__c where id =:so_Id]; 
        system.debug('Sales Order +++ ' + so.name);
        string acc = so.GD_Account__c;
        system.debug('Account Name ++ ' + acc);
        addList = [select id,name,GD_Type__c,GD_Account__c,GD_Address_1__c,GD_Address_2__c,GD_Address_3__c from GD_Address__c where GD_Account__c =:acc and  GD_Type__c = 'BILL_TO' Limit 1];
    }
}

Test Class
 
@isTEst
public class GD_SalesOrderPrintableViewTest {

    
    public static testmethod void testData(){
        
        Account acc = GD_TestDataFactory.createCustomer('Acc1','Customer');
        insert acc;
        
        Account acc1 = GD_TestDataFactory.createCustomer('Acc1','Customer');
        insert acc1;
        
        GD_Address__c address = new GD_Address__c(GD_account__c = acc.id, GD_Address_1__c = 'address 1', GD_Address_2__c = 'address 2', GD_Address_3__c = 'address 3');
        address.GD_Type__c = 'BILL_TO';
        address.GD_Account__c = acc1.id;
        insert address;
        
        GD_Order__c ord = new GD_Order__c(GD_Account__c = acc.id);
        insert ord;
        
        GD_Inventory_Organization__c inOrg = new GD_Inventory_Organization__c(Name = 'Test'); 
        insert inOrg;
        
        GD_Item_Master__c imas = new GD_Item_Master__c(GD_Item_Code__c= '001122', GD_Unit_Price__c = 1, GD_Inventory__c = inOrg.id);
        insert imas;
        
        GD_Order_Line_Item__c oli = new GD_Order_Line_Item__c(name = 'test',GD_Unit_Price__c = 10, GD_Quantity__c = 2,GD_Item__c = imas.id, GD_Vat__c = 2);
        oli.GD_Sales_Order__c = ord.id;
        oli.GD_Retail_Price__c = 1;
        insert oli;
        
        
        ApexPages.StandardController sc = new ApexPages.standardController(oli);
        GD_SalesOrderPrintableView controller = new GD_SalesOrderPrintableView(sc);
        
        ApexPages.StandardController sc1 = new ApexPages.standardController(imas);
         GD_SalesOrderPrintableView controller1 = new GD_SalesOrderPrintableView(sc1);
        
        
    }
    
}

Thanks in advance,
Soundar.​​​​​​​
manju manju 12manju manju 12
an amazing one onmovies apk (http://https://onmoviesapp.fun/)