Newer Version Available
Testing
You can also execute the CLI command for running Apex tests (force:apex:test:run) from within third-party continuous integration tools, such as Jenkins.
To run Apex tests from the command line:
1sfdx force:apex:test:runThis command runs all Apex tests in the scratch org asynchronously and then outputs a job ID. Pass the ID to the force:apex:test:report command to view the results. The results include the outcome of individual tests, how long each test ran, and the overall pass and fail rate.
1sfdx force:apex:test:report --testrunid 7074C00000988axUse the --resultformat parameter to run the tests synchronously. The command waits to display the test results until all tests have completed.
1sfdx force:apex:test:run --resultformat humanUse parameters to list the test classes or suites to run, specify the output format, view code coverage results, and more. For example, the following command runs the TestA and TestB tests, provides results in Test Anything Protocol (TAP) format, and requests code coverage results.
1sfdx force:apex:test:run --classnames TestA,TestB –-resultformat tap --codecoverage