Well, we know two things to be true: we promised more on the Salesforce CLI, and we promised to stay true to our name and publish content weekly – so here I am bringing you yet more Salesforce CLI!
This time we are going to dive into the sfdx force:apex command and explore these capabilities in more detail:
- force:apex:execute – execute anonymous Apex code
- force:apex:log:get – fetch a debug log
- force:apex:log:list – list debug logs
- force:apex:log:tail – start debug logging and display logs
- force:apex:test:report – display test results
- force:apex:test:run – invoke Apex tests
Most of these are available via the Salesforce UI already. For example:
- You can execute Apex anonymously via the Dev Console, but can you save it and easily rerun it?
- You can run tests via Apex Test Execution, but it’s not so easy to generate a report and share it with developers.
- You can access and view logs in the UI, but have you tried to read them or actually try to find any of your debug statements?
Without further ado, watch part 3 of ‘Getting started with the Salesforce CLI’.