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
Bryan Leaman 6Bryan Leaman 6 

Could not run tests on class <classid> because: connection was cancelled here

I'm constantly unable to complete tests because of this error in our sandboxes. If I keep running them over and over they usually complete normally eventually, but it can waste a half hour of my time to get them to complete so I have an accurate test coverage percentage on the class in question.

This has been a problem for over a year, but has been getting worse in the last few months.
Has anyone found a solution to this? This kills my productivity. I've cleared all test history, emptied the org's recycle bin, but no progress. Seems the only thing that helps is to refresh the sandbox (which I can't do right now because it's a shared environment).
Bryan Leaman 6Bryan Leaman 6
No solution that I know of. Salesforce still generates this error for me consistently. I usually have to run tests 3-4 times before they start completing normally and updating test coverage in the org. When this error occurs I will often see that all the tests completed, but the classes' test coverage hasn't been updated. 
anka lexanka lex
Hi Bryan,
Looks the issue is with paraller Apex Testing, pleas follow the steps and may help to resolve your issue.
Bryan Leaman 6Bryan Leaman 6
We've never been able to use parallel testing, so it's disabled already. The only "work around" is that I have to keep runing tests over and over until they finally complete without the "... connection was cancelled here" message. So if I have to run all tests, I just pick about 3 or 4. Then I can clear test history and run all tests and that usually works. It's just a huge waste of my time. 
Martín Lindsey MartínezMartín Lindsey Martínez
Al parecer esto sucede cuando se ejecutan programas con procedimientos muy tardados, mi opinion es que mata el tiempo del CPU y devuelve este error, mi posible solución es que se ejecuten pruebas unitarias y no por modulos. Alguién tiene alguna sugerencia?
Bryan Leaman 6Bryan Leaman 6
Martin, This error can happen on the smallest of test class methods. The only thing that appears consistent is that it occurs most frequently after deploying code. Of course, this is constant in the developer org ... that's why I'm running the test -- to see that my code change is not causing problems.
Jake Backues 15Jake Backues 15
This is happening more and more often for me. A solution I have found is to use the developer console and run tests Synchronously but unchecking Test > Always Run Asynchronously