-
Chained queuable jobs invoked through trigger.
System.AsyncException: Maximum stack depth has been reached.
Class.Qapex.execute: line 14, column 1I am new to salesforce. I want to know how to write a test class for the below code. I have chained 1 child job.
xParent queueable class:
public with sharing class Qapex implements Queueable{
private list L;
public Qapex(List a) {
this.L= a;
}
public void execute(QueueableContext q){
list LA= new list();
for(account f: this.L){
account acc= new account();
acc.Name= 'queable name' + f.Name;
LA.add(acc);
}
INSERT LA;
system.enqueueJob(new Qapex1());
}
}
Child queueable class:
public with sharing class Qapex1 implements Queueable{
public void execute(QueueableContext QC){
account ac = new account(name= 'new name');
insert ac;
}
}
Trigger:
trigger QapexTgr on Account (before insert) {
if(trigger.isBefore){
if(trigger.isInsert){
system.enqueueJob(new Qapex(trigger.new));
}
}
}
Parent queuable test class:
@istest
public with sharing class QapexTCLS {
public testmethod static void QapexTCLSM(){
Account a= new Account();
a.Name= 'test account';
insert a;
test.startTest();
system.enqueueJob(new Qapex(trigger.new));
test.stopTest();
account acc= [SELECT ID, name FROM account WHERE ID = : A.ID];
system.assertEquals('test account', a.name);
}
}
Child queueable test class:
@istest
public class Qapex1TCls {
@istest
public static void Qapex1TClsM() {
account a= new account(name= 'qapextestname');
insert a;
test.startTest();
system.enqueueJob(new Qapex1());
test.stopTest();
account ac= [select id, name from account where id= : a.id];
system.assertEquals('qapextestname', a.name);
}
}
ERROR:
QapexTCLS.QapexTCLSM Fail System.AsyncException: Maximum stack depth has been reached.
Class.Qapex.execute: line 14, column 1
This class name's value is invalid: Qapex1TCls. Provide the name of an Apex class that has test methods.
Log In to reply.
Popular Salesforce Blogs

A Nonprofit's Success with Salesforce
Case Study: Nonprofit Organization Leverages Salesforce for Growth Organization: The Community Foundation Challenge: The Community Foundation struggled to manage donor relationships, track donations effectively, and…

Explore The Application Network | Salesforce Developer Guide
Let’s Find Why Is Integration So Challenging? The Fourth(4th) technological revolution is upon us. Connectivity across people, applications, data, and therefore the Internet of Things…

Learn All About Apex in Salesforce | The Developer Guide
What is Apex in Salesforce? Apex is a strongly typed, object-oriented programming language that allows developers to run flow and transaction control statements on Salesforce…
Popular Salesforce Videos
The Salesforce and Stripe Integration Solution
Salesforce professionals choose us because we’re different. Our intuitive software connects Salesforce with Stripe and is simple to set up and configure and safe and…
How to Find Queries that Target a Data Extension in Salesforce Marketing Cloud
In this video, Cameron Robert shows how to find SQL queries in Automations that affect a specified Data Extension in Salesforce Marketing Cloud. Key Moments:…
How to use Salesforce Data to drive producivity and greater data capture
How do you encourage and drive better quality data entry into Salesforce by Salespeople? How do you use that data to drive productivity and proactive…