I want to run all unit tests on my org and download the code coverage report. The best for me is editable excel format. Is it somehow possible? Do you know any useful tools for apex unit tests to generate the report with classes code coverage?
[SalesForce] tool to run all tests and generate a coverage report
Related Solutions
You can force a run of all tests when deploying using the Force.com migration tool which is a wrapper over Ant. Set runAllTests=true when deploying to simulate a production like deployment where all tests are run while deploying. To rollback if test classes fail, set the rollBackOnError deployment option to true.
Here is the reference documentation, look around page 17 (Deploying Code) http://www.salesforce.com/us/developer/docs/daas/salesforce_migration_guide.pdf
By default, no tests are run in a deployment to a non-production organization, such as a sandbox or a Developer Edition organization.
To specify tests to run in your development environment, set a testLevel deployment option. For example, to run local tests in a deployment and to exclude managed package tests, add the testLevel="RunLocalTests" parameter to the deploy target.
<target name="deployCode">
<sf:deploy username="${sf.username}" password="${sf.password}"
sessionId="${sf.sessionId}" serverurl="${sf.serverurl}"
deployroot="codepkg" testLevel="RunLocalTests">
</sf:deploy>
</target>
Running a Subset of Tests in a Deployment
If the code coverage of an Apex component in the deployment is less than 75%, the deployment fails. If one of the specified tests fails, the deployment also fails. We recommend that you test your deployment in sandbox first to ensure that the specified tests cover each component sufficiently. Even if your organization’s overall code coverage is 75% or more, the individual coverage of the Apex components being deployed can be less. If the code coverage requirement isn’t met, write more tests and include them in the deployment. To run a subset of tests, add the testLevel="RunSpecifiedTests" parameter to the deploy target. Specify each test class to run for a deploy target in a child element within the sf:deploy element. Add the test class name within the tags. Add as many runTest tags as you need, one for each test class.
<target name="deployCode">
<sf:deploy username="${sf.username}" password="${sf.password}"
sessionId="${sf.sessionId}" serverurl="${sf.serverurl}"
deployroot="codepkg" testLevel="RunSpecifiedTests">
<runTest>TestClass1</runTest>
<runTest>TestClass2</runTest>
<runTest>TestClass3</runTest>
</sf:deploy>
</target>
Best Answer
You can use the ApexCodeCoverageAggregate object available in the Tooling API to obtain coverage information. However, this is not going to come down in an excel format. You can request this data in JSON or XML though, both of which are very easy to work with and can easily be converted to a CSV via an online tool or programmatically using a node, python, etc. library.