Questions tagged [asynchronous-testing]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
28 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
1answer
57 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 ...
4
votes
2answers
344 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. ...
0
votes
1answer
406 views

How to call AsyncApexJob in test class from batch class finish method

here code is passed and code code coverage is not coverd, Please help me any one Test class test.startTest(); // UpdateOppToInitialize.UpdateOppToInitialize(); UpdateOppToInitialize obj = new ...
2
votes
1answer
712 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
2answers
591 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
1answer
112 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 ...
11
votes
1answer
2k 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 ...
1
vote
2answers
452 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
2answers
781 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
1answer
113 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
1answer
70 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
2answers
1k 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
1answer
869 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
1answer
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
1answer
68 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
0answers
127 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
1answer
1k 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....