0

Pretty new with salesforce dev. So forgive me. I am doing a SOQL query and then updating records. The trick here is . I am grabbing my query from two custom fields which are in the Custom Settings . My code works fine records are getting queried and updated. I am having big trouble in making test class for this . Help is appriciated . Here is my Apex Class -

 public with sharing class textInputsConsecond implements Schedulable   { 
 public list<Lead>  quo{get;set;}


 public void execute(SchedulableContext ctx){ 
   quo= Database.query(Lead__c.getInstance().Database_Query__c + 
   Lead__c.getInstance().Database_Query2__c);
   for(Lead ldt :quo){
   //Update those leads with new owner ID
   ldt.OwnerId = '00G3B000001hp6VUAQ';

    }

   update quo;
 }
 }

Here is the screenshot of my Query in the Field in custom settings - enter image description here

So my query is basically Database Query field + Database Query2 Field

  • 1
    I am having big trouble in making test class for this - What have you tried so far and where are you stuck? Have you taken a look around on trailhead for resources on Apex Testing? – Jayant Das Feb 18 at 22:04
  • Hello Jayant. So here he what did so far with the test class . Inserted some test leads and tried to update them – deboniar Feb 18 at 22:08
  • 1
    Custom Settings are data. You'll need to create Custom Settings instances in your unit test setup that include a query to be run in test context, along with responsive Leads. I've linked a couple of canonical questions that connect to more resources. – David Reed Feb 18 at 22:29