Questions tagged [asynchronous-testing]
The asynchronous-testing tag has no usage guidance.
19
questions
2
votes
1
answer
518
views
How to create a no-code test for a Asynchronous Path in Flow?
I'm trying to create some tests for Flows using the no-code test feature within Flow builder.
According to this article, the ability to add tests for scheduled paths was rolled out in Winter '23, but ...
2
votes
1
answer
1k
views
Testing asynchronous flow in Apex test method
I am somewhat vexed by this and I would like a little guidance.
I have a flow that fires on record create or update and I have written an Apex test class to test that it works as intended. I have set ...
0
votes
0
answers
63
views
Possible to keep (or equivalent of) a public static variable across test classes in an async test run?
I have test methods I want to use from test class A in test class B, in an async test run if test A runs before Test B I don't want to invoke the test A methods in test B because they already ran and ...
2
votes
1
answer
215
views
Unit Tests for Asynch Callout from a LWC
I have implemented several callouts using the Continuation object based on the documentation here. But there is no reference for unit tests. The section in the developer guide only shows how to test ...
5
votes
2
answers
4k
views
Queueable apex still executes in test context even if Enqueue Job is not called between Test.startTest() and Test.stopTest()
According to Salesforce docs:
All asynchronous calls made after the startTest method are collected
by the system. When stopTest is executed, all asynchronous processes
are run synchronously.
...
3
votes
1
answer
3k
views
Queueable Apex in a Before Trigger
I am attempting to create logic that, on Contact record insert or update, will compare the Phone value of the record to another reference object and conditionally populate a checkbox as a result of ...
5
votes
2
answers
1k
views
Automated testing of chained Queueable jobs in Salesforce
I am currently writing a queueable class for asynchronous processing in my triggers since triggers do not allow callouts. I am going achieve it by calling a class which implements the queueable ...
1
vote
1
answer
252
views
Command pattern with batch finish method
To chain a execution of a batchable object, I pass the batchable contructor a ICommand.
public interface ICommand {
void Execute();
}
When testing this approach I create a test ICommand which ...
15
votes
1
answer
9k
views
How do I test asynchronous Apex?
This is a canonical question and answer developed by the community to help address common questions. If you've been directed here, or your question has been closed as a duplicate, please look through ...
3
votes
2
answers
1k
views
Can Salesforce Platform Events be Relied on as an Async Solution?
Recently I was working on a project where, in order to deal with recursion and governor limits, the previous developer decided to send Platform Events, with the expectation that the very same ...
1
vote
2
answers
2k
views
Catching exceptions thrown from scheduled job during test execution
I am curious about how to test a scenario when a scheduled job throws an exception. Imagine this is how the schedulable class looks:
global class ExceptionScheduler implements Schedulable {
...
1
vote
1
answer
121
views
elegant way to test WSDL based continuation callouts
I've read this document about testing Asynchronous Callout from an Imported WSDL.
But is there a way to do the same test without instantiate an HttpResponse? because copy-pasting a string with an ...
1
vote
1
answer
131
views
Asserting On Asynchronous Behavior
I have a future method with some logic and I have written Test class for that.
Calling future method inside test.startTest() and test.StopTest() in test class and asserting the values, in this case i'...
6
votes
2
answers
2k
views
Disable Parallel Test vs. Always Run Asynchronously in Dev Console - Who wins?
I love to run my tests in the Dev Console with the Always Run Asynchronously checkbox enabled as it saves time.
On the other side during our automated Nightly Test run I would like to disable ...
5
votes
1
answer
2k
views
Queueable class throws Uncommitted Work Pending error in one test, but not others [duplicate]
I noticed yesterday that one of my new test cases was failing, and determined from the logs that I was getting the beloved System.CalloutException: You have uncommitted work pending. Please commit or ...
3
votes
1
answer
1k
views
How to write test classes for Continuation Controller (using Async WSDL class)
I have implemented Continuation concept with the Asynchronous WSDL class, in a controller of page. So, I facing difficulties while writing test classes for the same.
For my requirement I have ...
0
votes
1
answer
80
views
Regarding apex class to Test Class
I have A Given Sample Apex Code
@HttpGet
global static String doGet(){
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
try{
...
0
votes
0
answers
182
views
Tests passing with 0% coverage
I'm pretty new to apex.
My test classes are passing. But the class is showing zero % coverage
(none of the lines in the actual class were hit (highlighted blue)... which does not make sense.)
Any ...
3
votes
1
answer
2k
views
Testing multiple asynchronous processes
I have a test that for it's data setup I need to fire multiple asynchronous processes. I have a suspicion, that they do not finish sequentially one after another.
I think Test.startTest()/Test....