note: I'm stuck in an org-centric world, so CircleCI is setup w/my dev sandbox, not scratch orgs.

Recently, I set up a CircleCI build to run my sandbox orgs tests w/RunLocalTests on each pull request. I'm running into problems with tests that don't like to be run in parallel mode. Which is a shame, because 10 minute test runs are far better for my sanity. Fixing the tests is underway, but it looks like a good chunk of them are vendor supplied and make use of Pricebook in a way that is unpleasant for testing.

In CircleCI I have populated "artifacts" with the test run results in json and xml, so my thought is to somehow parse one of those files into a list of test classes to re-run using the sfdx force:apex:test:run command with the --synchronous arg.

Is there a way to easily get the failed tests using sfdx commands, or am I stuck with file reading?

  • 1
    You can get what you need out of the Tooling API by querying the ApexTestResult and ApexTestQueueItem sObjects. That's not quite what you're asking, but it's easy to script.
    – David Reed
    Nov 24, 2020 at 20:37
  • Thanks @DavidReed, that's the conclusion I was coming to, eventually as well. It'll be a bit more scripting work, but like you said, not the worst thing in the world.
    – torpy
    Dec 7, 2020 at 16:41
  • Heads up that you are going to find some odd inconsistencies, with certain classes of deadlock failures not producing ApexTestResult records but an error shown on the ApexTestQueueItem.
    – David Reed
    Dec 7, 2020 at 18:07


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.