2

I love the option of running test methods from VSCode by clicking on Run Test link that appears below the @isTest annotation. This works well but when a test method fails, I go ahead and add a System.debug() statement to troubleshoot where it is failing. But it never prints the debug statements from the test method or actual method.

I tried running sfdx force:apex:test:run --loglevel trace but still it just prints the result and doesn't print the debug statements.

Can someone help me on this?

2

You can use:

sfdx force:apex:log:get

to get the last log file or use:

sfdx force:apex:log:tail --color

to stream the log file output to your console. (See e.g. Streaming Debug Logs to your console.)

  • Ok. I thought we can fiddle with arguments passed to the command sfdx force:apex:test:run and get debug statements printed along with pass or fail result. That would have been so handy. – javanoob Jun 13 at 20:29
  • @javanoob Not AFAIK. But the tail option is pretty nice. – Keith C Jun 13 at 20:32
  • You are right. This workaround is lot better than going into the developer console for logs. – javanoob Jun 13 at 20:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.