Force tooling API for unit tests

44 views
Skip to first unread message

Matt Addy

unread,
Jun 28, 2020, 10:14:04 AM6/28/20
to Illuminated Cloud Q&A
Hey Scott,

I did a 30-day trial of WebStorm to evaluate support for lwc. My trial is up so I switched back to IntelliJ CE but found my unit tests are not completing, both in Salesforce and (obviously) IntelliJ. It just runs, runs, runs... 

I switched back to WebStorm, and the unit test finishes in a couple of seconds.

I looked through my settings in both IDEs and didn't see a difference that would be applicable here. Looking for ideas.

I believe WebStorm is using a different API then IntelliJ for executing unit tests, because IntelliJ is showing the unit test execution under Apex Test Execution in Setup, while WebStorm is not. But my "Prefer Tooling API for.." settings are identical between the two IDEs.

Any thoughts on what is happening?

Thanks,
Matt

Screen Shot 2020-06-28 at 10.12.18 AM.png

Scott

unread,
Jun 28, 2020, 11:17:34 AM6/28/20
to Illuminated Cloud Q&A, Matt Addy
Matt, IC always uses the Tooling API to execute unit tests. However, you can configure whether it does so synchronously or asynchronously when running tests from the same containing class under Illuminated Cloud>Configure Application>Unit Tests and Code Coverage via Always run unit tests asynchronously. By default it will run tests from the same test class synchronously because that bypasses the queue and can be faster, but it can also lead to false negatives (or at least could in the past; not sure if Salesforce has fixed that), hence the need for that option.

You might try changing that config option to see if it resolves the issue for you. If not, I'm happy to take a look at debug logs enabled for Unit Testing.

Regards,
Scott

Matt Addy

unread,
Jun 28, 2020, 11:47:09 AM6/28/20
to Illuminated Cloud Q&A, Scott, Matt Addy
Thanks for the quick response Scott. I greatly appreciate it.

It seems to have fixed itself after I did the following.
  1. Toggle "Always run unit tests asynchronously" on
  2. Run the unit test, same issue
  3. Toggle "Always run unit test asynchronously" off
  4. Run the unit test, fixed
This seems to have fixed the issue. 

Does the "Always run unit tests asynchronously" option use a different API? Or a different method that makes it show up in Apex Test Execution?

It's not showing up in Apex Test Execution anymore, and it works.

Thanks,
Mat

Scott

unread,
Jun 28, 2020, 11:49:56 AM6/28/20
to Illuminated Cloud Q&A, Matt Addy, Scott
Matt, they both use the Tooling API but different REST endpoints:

Note runTestsAsynchronous and runTestsSynchronous in that list.

Given that you were seeing the same behavior outside of IC, it sounds like something got into a weird state temporarily and by "jiggling the wire", so to speak, it got back into the right state. That's my guess based on the provided info at least.

And I'm not sure if synchronous runs show up in test execution because they bypass the queue.

Regards,
Scott

Aidan Harding

unread,
Jun 29, 2020, 4:22:17 AM6/29/20
to Illuminated Cloud Q&A, Scott, Matt Addy
Hi Matt,

We've been seeing Apex Test executions taking very long times to complete and/or never completing over the past week or so. This often happens in the weeks approaching a Salesforce major release release - certain sandboxes become unusable for a while. 

It's going to be hard to reach firm conclusions because that sort of slow-down is intermittent, but it's worth considering that the problem may be with the Salesforce instance(s) rather than with IC. Especially if you're seeing the same sort of results when running through the setup pages. 

Scott

unread,
Jun 29, 2020, 10:29:37 AM6/29/20
to Illuminated Cloud Q&A, Aidan Harding, Scott, Matt Addy
If anyone continues to see this and can get a good debug log of the test execution, I'd love to see it. My guess is that it's going on inside of Salesforce and not IC because nothing has changed in this area in a very long time, but a log file should help me to know for sure.

Regards,
Scott

Matt Addy

unread,
Jun 29, 2020, 10:49:44 AM6/29/20
to Illuminated Cloud Q&A, Scott, Aidan Harding, Matt Addy
Thanks for the info Aidan.

Yeah I'm confident it's a Salesforce thing. When I run the unit test manually from Apex Test Execution under Setup, it spins forever. When I run the unit test from the Developer Console it finishes in a few seconds. I was drawing a parallel to the IDE, and hoping to understand which setting would force tests to run using the same "mode" as the Developer Console. 

Thanks,
Matt

Scott

unread,
Jun 29, 2020, 10:57:33 AM6/29/20
to Illuminated Cloud Q&A, Matt Addy, Scott, Aidan Harding
I just passed on a link to this thread to some folks at Salesforce since it seems to occur outside of IC and in the standard Setup UI. It's possible that they might reach out to one or both of you for assistance with reproducing/debugging it.

Regards,
Scott

Scott Wells

unread,
Jul 14, 2020, 10:51:16 AM7/14/20
to Illuminated Cloud Q&A, Scott, Matt Addy, Aidan Harding
Is anyone still seeing this behavior or has it magically resolved itself?

Regards,
Scott

Matt Addy

unread,
Jul 14, 2020, 11:47:29 AM7/14/20
to Illuminated Cloud Q&A, scott...@gmail.com, Scott, Matt Addy, Aidan Harding
Hi Scott,

Since flipping the asynchronous option back and forth my tests have been running fine. 

Thanks,
Matt

Jason Hardy

unread,
Apr 30, 2025, 12:09:19 PMApr 30
to Illuminated Cloud Q&A, Matt Addy, scott...@gmail.com, Scott, Aidan Harding
Hi All, I have started running into a similar issue. My unit tests are always getting done async. I have tried toggling the always run async on and off but that doesn't appear to have helped. I tried going to the logging debug link; however, I got a 404 error. Can I get some info on how to enable the debugging needed and I'll go ahead and run the debug. 

Thanks!

Scott

unread,
Apr 30, 2025, 12:10:28 PMApr 30
to Illuminated Cloud Q&A, Jason Hardy
Hi, Jason. The URL changed when the site was overhauled a bit back. Here's the current one:


Please enable debug logging for unit test execution, reproduce the behavior, and share the resulting idea.log with me via email.

Regards,
Scott Wells
Reply all
Reply to author
Forward
0 new messages