• Harshad KokaTe 22
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
This is my method of test class which is giving full coverage but while deployment to production its giving an error System.LimitException: TR1:Too many SOQL queries: 101
Stack Trace: (TR1)
For following method:


public static testMethod void InvoicePreviewSingle(){
        
        // Starting Test
        Test.startTest();
        invoiceUtilityListData ();
        test.setCurrentPage(Page.BulkInvoicePreview_v1);
        BulkInvoicePreview_v1 invoicePreview = new BulkInvoicePreview_v1();
        
        
        invoicePreview.recordType = Invoicing_Constants.CONSULTING;
        invoicePreview.timesheet1.TR1__Week_Ending__c = System.today();
        invoicePreview.timesheet.TR1__Week_Ending__c = System.today();
        invoicePreview.InvoiceType = 'Single';
        invoicePreview.invoiceDate = System.today().format();
        invoicePreview.showDisabled = true;
        invoicePreview.statusList.add('Approved');
        
        System.assertEquals(4, accList.size());
        System.assertEquals(accList[0].id ,consultingClosingReport.TR1__Account__c);
        System.assertEquals(2, timesheetList.size());
         System.assertEquals(2,timesheetDetailList.size());
        
        invoicePreview.ContinueRecord();
        
        // Setting the Current Page     
       test.setCurrentPage(Page.BulkInvoice_v1);
        
        ApexPages.CurrentPage().getparameters().put('ids', String.valueOf(accList[0].Id));
        ApexPages.CurrentPage().getparameters().put('closingReportIds', String.valueOf(consultingClosingReport.Id));
        ApexPages.CurrentPage().getparameters().put('invoiceDate', String.valueOf(System.today()));
        ApexPages.CurrentPage().getparameters().put('jobType', Invoicing_Constants.CONSULTING);
        ApexPages.CurrentPage().getparameters().put('weekEndDate', String.valueOf(timesheetList[0].TR1__Week_Ending__c));
        ApexPages.currentPage().getParameters().put('value', String.valueOf(0));
        ApexPages.currentPage().getParameters().put('isPreview', 'true');
        ApexPages.currentPage().getParameters().put('InvoiceType', 'Single');
        ApexPages.currentPage().getParameters().put('isPrint', 'true');
        
        BulkInvoiceController_v1 invoiceCtrl = new BulkInvoiceController_v1();
        System.assertEquals(0, invoiceCtrl.invoiceList.size());
        
        invoicePreview.showInvoices();
        
        invoicePreview.nextList();
        invoicePreview.prevList();
        
        invoicePreview.showDisabled = true;
        invoicePreview.ContinueRecord();
        
        invoicePreview.showInvoices();
        
        // Calling Send Email method
        invoicePreview.SaveAndSendEmail();
        
        invoicePreview.getType();
        invoicePreview.getPeriod();
        invoicePreview.getHasRecords();
        invoicePreview.onChangeFilter();
        invoicePreview.getInvoicingType();
        invoicePreview.getTimesheetStatusOptions();
        
        invoicePreview.updateTimesheets(timesheetList, 'Printed', String.valueOf(System.today()));
        invoicePreview.updatePrintStatus();
        
        //Stopping Test
        Test.stopTest();
               
    }