Skip to main content
Jancy Mary が「#Apex」で質問
Hey guys,

Need some help, I have a apex class with soql query on Reports of type (Task & Events) in the UAT, the reports for now returns 0 records as I have some filters as Date = Last 30 Days, I'm not able to cover the query line in test class as the report result 0 count, if the same report result atleat 1 record the query line are covered in the test class. Rest all the code lines are covered except these query lines.

Also a question, while moving the code from sandbox to production through change set will the test class validate against production org data or sandbox.

Thanks in advance,

Jancy Mary
10 件の回答
  1. 2016年6月22日 10:38
    Hi Yuchen,

    Well thanks for your reply on this, you are partially correct, I actually resolved this few days back.

    1. Used @isTest(seeAllData='true') on the top class level and just called the methods of controller in the Test Class.

    2. As it was my sandbox on which I had my report and controller classes defined, I just created few test records to make the reports have some records under it, this resolved half of the problem. I wrote the below query in my Test Class so that I get some records from the report to pass the Test Class.

    List <Report> reportList1 = [SELECT Id, DeveloperName FROM Report where DeveloperName = 'my_Report_API_Name'];

    @isTest(seeAllData='true')

    public class last30DayCallsController_TestHelper

    {

    public static Integer count=0;

    public static integer Target;

    public static testMethod void table(){

    test.startTest();

    List <Report> reportList1 = [SELECT Id, DeveloperName FROM Report where DeveloperName = 'my_Report_API_Name'];

    last30DayCallsController.Data1 data1 = new last30DayCallsController.Data1(600, Count);

    last30DayCallsController.getData1(); //controller method call

    last30DayCallsController.allPlcmt1(); //controller method call

    test.stopTest();

    }

    }

    Thanks for all help on this post,
0/9000