Ask Search:
Mark DwyerMark Dwyer 

Waiting for Test Report from Salesforce DX CLI

Hi all,

I am writing a build script to trigger tests with sfdx force:apex:test:run, and then to check the resulting report in order to fail/pass the build.

My question is, if I run sfdx force:apex:test:report --testrunid <SOME ID> --json, what statuses or other values returned can I use to determine the test job has completed before proceeding and checking passed vs failed test counts?

Does this command block until the test run job completes?  Or will I need to poll it periodically and read some field to determine when the job has completed?  I couldn't find any documentation on what is returned in the JSON output. and I don't have a large test suite to replicate a long running job to determine what I should be checking for.

I'm assuming I'll need to look at something in result -> summary -> outcome, but unsure which values.  I noticed there is a -w (wait) parameter, which seemed to possibly hint that the command blocks until the job either complets or times out?

Any help much appreciated.

Pratima ShrivastavPratima Shrivastav
Hi Mark,
Please post developer related questions on salesforce stack exchange or developer forum. You have better chances of getting an answer there.!/feedtype=RECENT&criteria=ALLQUESTIONS&