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
Kishan Kumar 77Kishan Kumar 77 

i have a custom label that contains a query which is using a past date as criteria for 'systemmodstamp' field.

How do I write a test class for a class that uses a query from custom label using a past date. I am running a query that fetches records of a custom object with a where clause as 
Select Id, Name, etc from custom_object__c where systemmodstamp >= 2014-11-15T13:00:00.000Z and systemmodstamp <= 2014-11-15T22:00:00.000Z.

Please help me to write a test class so that it satisfies the code coverage requirement.
mukesh guptamukesh gupta
Hi Kishan,

You don't need to use custom label in testy class , just insert new record of  custom_object__c,  and after that fetch by select Query 

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
Kishan Kumar 77Kishan Kumar 77
Hi Mukesh,

My class is basically a batch class and in my start method I am quering data which has to be passed in the execute method. So when I am calling my batch class in my test class it is not satisfying the code coverage as when my class is called in the start method I am using a condition which fetches data based on systemmodstamp field.

Is there a way I can create records which have systemmodstamp field value as my requirement?
Kishan Kumar 77Kishan Kumar 77
I have created my test data but when my batch class is being instantiated and invoked then the start method is fetching data from my custom object based on where clause as I have mentioned above. and since the systemmodstamp value does not matches with the value that I have provided , the execute method is not receiving any data from my start method