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
Sam Mohyee 12Sam Mohyee 12 

Deployment with single Apex test taking 15+ minutes to even START the test run...

Here's what I've been staring at for 16 minutes so far. 

User-added image

Deployed via SFDX, specifying a single apex test to run, which has less than 40 lines of code. Takes only a fraction of a second to run in scratch org or sandbox.

But when I deploy to Production, all components are validated within a minute or two, then the status switches to 'Running {testname}'.... and stays that way. For literally 15 minutes or more. Before the test is even started. 

I'm not finding a lot of posts on this issue. Plenty of people talking about the time it takes to actually run the test. But I'm talking about the time it takes to start running the tests. This isn't a one time thing, but it also isn't consistent. Sometimes the tests will begin running pretty much immediately. Sometimes I'll end up cancelling and redeploying because a 30 minute delay to START testing seems ridiculous even given Salesforce's standards. And when I do cancel and redeploy? Good chance it'll take a fifth of the time, for no apparent reason.

What I'd really like is some better communication during this process. Why is my test run delayed? What was prioritized ahead of it? How can I anticipate deployment times so it's not a complete crapshoot regardless of build size? 

Nathan E.Nathan E.
All good ideas for sure. I ran into this issue one time in a *very* time-sensitive deployment and here was my magic solution....changing the name of the test class. I never quite understood why, but that did the trick. I am not sure if that will work here, but I thought I would pass it along.
Subramani_SFDCSubramani_SFDC
do you have any debug logs level with FINEST ?

Before running a deployment, verify that the Apex Code log level is not set to FINEST. Otherwise, the deployment is likely to take longer than expected. If the Developer Console is open, the log levels in the Developer Console affect all logs, including logs created during a deployment.
Sam Mohyee 12Sam Mohyee 12

Interesting point! I do indeed have Apex Code set to FINEST in production log levels, at least for Dev Console. I'm not sure if I had the dev console open during the deployment, so I will try both with it open and without and see if it impacts test time.

However, it it didn't take 16 minutes for the test to run... it took 16 minutes for the test to BEGIN its run.. so I'm not positive this is the reason. 

Raj R.Raj R.
Here is an interesting question posted to stackexchange that has an answer with a lot of votes that may help. 

https://salesforce.stackexchange.com/questions/8346/how-to-reduce-the-test-class-execution-time-while-deploying
Alexander NunesAlexander Nunes

currently working on an native Android app
Visit in the https://social.technet.microsoft.com/Profile/rrsoares

Read more in https://social.msdn.microsoft.com/Profile/rrsoares