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
Mario CMario C 

Test Class for Queueable Apex Chain passing a list ids

Hi,

I've implemented queueable apex on 2 chained classes: class a and class b. 

In Class A, when the class 2 gets invoked a list gets also passed into class b.

while the test cflass for class a is fine, I am unable to get coverage for class 2. 

Any ideas about how to write the test class for this scenario?
 
public class classA implements Queueable, Database.AllowsCallouts {

    
    public void execute(QueueableContext context) {

do something...

List<id> myList;

System.enqueueJob(new blassB(myList);

....

 
Gabriel C FerreiraGabriel C Ferreira
Hi Mario,

When you make a test class, is best recommended that you test only one "feature" at time, to guarantee that your chained class is working regardless of who invoked it. So, the best practice is to make a separate test method to test only the class 2.

If you have to test the chained flow, be sure that your test code is between Test.startTest() and Test.stopTest().
Mario CMario C
Hi Gabriel,

Thanks for your response.

I am testing the second class creating some dummy records and list of ids,  but I get a Class List<Id> must implement the Queueable interface error...any idea?
Gabriel C FerreiraGabriel C Ferreira
Can you share the error and the test class?
Ryan ZimmermanRyan Zimmerman
Hey Mario,

Your example Class A implements the Queueable Interface but has no constructor. Does your class B implement the queueable interface and have a constructor?