dimanche 9 avril 2017
·
2 minutes de lecture
Unit testing is great. There are tons of tools available out there to generate nice coverage summaries for various languages. Just to name a few, I can think of Jest, Mocha, hpc and the list goes on.
There are multiple ways to execute & visualise your Apex tests on the Force.com platform. However, if you are working on an open-source project, how would you expose that coverage to potential users if they do not have access to your Salesforce developer org?
apexcov
To fight that challenge, I've worked on an utility called apexcov
producing a test coverage summary, in a similar format as the produced by the gcov
utility. One cool benefit is that it can be used in conjunction with services like Code Climate and Coveralls.
If you have Go installed, simply execute in a shell:
$ go get -u github.com/jpmonette/apexcov
When the package is installed, using the CLI tool is really simple: feed in your --username
, --password
and the utility will generate a file with your current code coverage stored in a ./coverage
sub-folder.
With that coverage data in hand, you can use utilities like node-coveralls
to expose your coverage publicly on Coveralls, or codeclimate-test-reporter
for Code Climate - you can see an example with the Q for Salesforce library.
For more information, the apexcov repository on Github provides details on how to setup popular Continuous Integration services like Travis CI and CircleCI.