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
venkateshyadav1243venkateshyadav1243 

Test class @70 %

Hi am not able to cover test calss can please any one help me where am missing thanks for your help

Trigger.

trigger updatingadressdummy on KYC__c (after insert,after update) {

    // for billing 1
    set<id>kycidb1=new set<id>();//set for kyc
        set<id>kycids1=new set<id>();//set for kyc
    set<id>kycidb1c1=new set<id>();//set for contact
    list<kyc__c>kyclist=new list<kyc__c>();//1st list for kyc
    list<kyc__c>kyclist1=new list<kyc__c>();//2nd list for kyc
    list<account>acc=new list<account>(); //list for account
    list<contact>contactb1=new list<contact>();//list for contact
    list<kyc__c>kyclistcb1=new list<kyc__c>();//1st list for contact in kyc
    list<kyc__c>kyclistc1b1=new list<kyc__c>();// 2 nd list for  contact  inkyc
   
  if (!supporttoaccountupdatetrigger.hasAlreadyCreatedFollowUpTasks())
   {
   
   
        for(kyc__c k:trigger.new)
        {
            if(k.Billing_Address_1__c!=NULL)
           {
            kycidb1.add(k.Billing_Address_1__r.id);
            }
             if(k.Shipping_Address1__c!=NULL)
            kycids1.add(k.Shipping_Address1__c);
           
            if(k.Contact_Person_b1__c!=NULL)
            {
            kycidb1c1.add(k.Contact_Person_b1__r.id);
            }
           
         
        }
       
       
        // for billing 1 kyc
        kyclist=[select id,Billing_Street1__c,Billing_City_1__c,Billing_Country_1__c,Billing_State_Province1__c,Billing_Zip_Postal_Code1__c,Billing_Telephone_number1__c,Billing_Fax_number1__c from kyc__c where Billing_Address_1__c=:kycidb1];
       
        //for billing 1 conatact 1
       kyclistcb1=[select id,Contact_Person_Name_b1__c,Mobile_b1__c from kyc__c where Contact_Person_b1__r.id=:kycidb1c1];
       
        //contact for billing1
        contactb1=[select id,firstname,lastname,mobilephone from contact where id=:kycidb1c1];
       
         //account for billing 1                                                                  
        acc=[Select Id, BillingStreet,BillingState,Billingcity,BillingCountry,BillingPostalCode,Billing_Telephone_number__c,Billing_Fax_number__c,
                    ShippingStreet,ShippingCity,ShippingState,ShippingPostalCode,ShippingCountry,Shipping_Telephone_number__c,Shipping_Fax_number__c from Account where ID=:kycidb1] ; 
     
       
     
       
      //     billing 1  account
       
        for(kyc__c ky:kyclist)
        {
            for(account a:acc)
            {
                ky.Billing_Street1__c=a.BillingStreet;
                ky.Billing_City_1__c=a.billingcity;
                ky.Billing_Country_1__c=a.BillingCountry;
                ky.Billing_Zip_Postal_Code1__c=a.BillingPostalCode;
                ky.Billing_State_Province1__c=a.BillingState;
                ky.Billing_Telephone_number1__c=a.Billing_Telephone_number__c;
                //ky.Billing_Fax_number1__c=a.Billing_Fax_number__c;
               
                kyclist1.add(ky);
              
            }
        }    
       
        supporttoaccountupdatetrigger.setAlreadyCreatedFollowUpTasks();
               update kyclist1;
              
              
              
          //   for billing one in cantact  
              
         for(kyc__c kyc1:kyclistcb1)
         {
            for(contact c1:contactb1)
            {
                kyc1.Contact_Person_Name_b1__c=c1.firstname + ' ' +c1.lastname;
                kyc1.Mobile_b1__c=c1.MobilePhone;
               
                kyclistc1b1.add(kyc1);
              
            }
        }    
       
        supporttoaccountupdatetrigger.setAlreadyCreatedFollowUpTasks();
               update kyclistc1b1;
              
              
                                                                                                                               
}                                                                         

}


test class

:

@isTest
private class testupdatingadressdummy
{
 
 
  static testMethod void teSupdatingadress()
  {


        account a=new account(name='test',Region__c='East',BillingStreet='test',BillingState='assam',Billingcity='kolkata',BillingCountry='india',BillingPostalCode='1234',Billing_Telephone_number__c='9000853067',
                    ShippingStreet='parnapalli',ShippingCity='hyderabad',ShippingState='karnataka',ShippingPostalCode='12345',ShippingCountry='india',Shipping_Telephone_number__c='1234567890');
        insert a;
       
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
       
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id,mobilephone='900867657');
        insert c;

        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
    
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=1000,Height__c=12,Label_Height__c=12,Hologram_Height__c=14,Holographic_Film_Height__c=15,Multimax_Seal_Height__c=16,Sleeve_Height__c=90,Foil_Stamping_Height__c=17,Width__c=22,Label_Width__c=23,Foil_Width_for_Supplies__c=24,Hologram_Width__c=25,Holographic_Film_Width__c=27,Holographic_Strip_Width__c=28,Sleeve_Layflat_Width__c=29,Sleeve_Width__c=30,Foil_Stamping_Width__c=31,Make__c='ACR',Model__c='GT800');
        insert opd;
       
        Quote__c qt=new Quote__c(Opportunity_Product_Detail__c=opd.id,Purpose_of_Sales__c='SEZ',Basic_Price_Each_item__c=23,Declaration_form_be_provided__c='No',TTR_Height__c=13,TTR_Width__c=12);
        insert qt;
       
        Purchase_Order__c sco=new Purchase_Order__c(Quote__c=qt.id,Opportunity__c=op.id,New_Flash_Aidc_Email_sent__c='venky@globalnest.com');
        insert sco;
                               
       Kyc__c kc=new kyc__c();
        kc.Sale_Confirmation_Order__c=sco.id;
        kc.Contact_Person_b1__c=c.id;
        kc.Contact_Person_Name_b1__c='Meenakshmi Goswami';
        kc.Mobile_b1__c='900867657';
        kc.Email__c='abc@gmail.com';
        kc.Opportunity__c=op.id;
        kc.Billing_Street1__c='test';
        kc.Billing_City_1__c='kolkata';
        kc.Billing_Country_1__c='india';
        kc.Billing_State_Province1__c='assam';
        kc.Billing_Zip_Postal_Code1__c='1234';
        kc.Billing_Telephone_number1__c='9000853067';
      
       kc.Billing_Address_1__c=a.id;
        kc.Contact_Person_b1__c=c.id;
        kc.Shipping_Address1__c=a.id;
        kc.Billing_Address_3__c=a.id;
               insert kc;
    
                      }
        }
ShashForceShashForce
Hi,

If you can open the trigger in the Developer Console and run tests, you should be able to see which code lines are missing test coverage and you should be able to tweek your test class accordingly. Please try this.

Thanks,
Shashank