Code Coverage

Apex Code Coverage indicates how many executable lines of code in your Apex Classes and Triggers have been exercised by unit tests. The Metazoa Snapshot Org Management product has an Apex Code Coverage Report that allows a Salesforce developer or administrator to run the unit tests for any Org, and see Code Coverage on a line by line basis. The report can be shared with team members or archived for compliance documentation.

Apex Code Coverage
Report for Salesforce Developers

The Salesforce Apex Code testing framework generates code coverage numbers for each Apex Class and Trigger. Code coverage indicates how many executable lines of code in your classes and triggers have been exercised by test methods. You must write test methods for your classes and triggers, and then run those tests to generate code coverage information. In addition to ensuring the quality of your code, unit tests enable you to meet the code coverage requirements for deploying or packaging Apex. To deploy Apex or package it for the Salesforce AppExchange, unit tests must cover at least 75% of your Apex code, and those tests must pass.

Our Metazoa Snapshot product has a report that runs selected Apex Tests for any Salesforce Org. You can see the number of lines covered, the number of lines that are not covered, and the percentage of coverage for each Apex Class. The Snapshot Apex Code Coverage report also shows each Apex Class or Trigger with line by line coverage information. This report is used by Salesforce Administrators and Developers to find Apex Classes that need additional coverage, and also to find unit tests that fail when they are executed. The report can be shared with team members or archived for compliance documentation. You can also set up the report to monitor a Salesforce Org and send out an email or Chatter notification if Apex Code Coverage falls below the desired level.

Snapshot also allows selected Apex Tests to be run before any deployment. This allows a Salesforce Administrator to select the tests that are most likely to succeed and provide enough coverage for the deployment to succeed. This capability can also be used to guarantee a certain level of Apex Code Coverage for Sandbox deployments, or deployments to a User Acceptance Testing Org. The short movie below shows how the Snapshot Apex Code Coverage report works, and also shows the Code Coverage options in the metadata deployment interface.

Apex Code Coverage Report

Overview

Metazoa Snapshot is a tool that provides an interface for managing Salesforce orgs. One of the key features of Metazoa Snapshot is the Apex Code Coverage Report. This report assists users in monitoring and managing the code coverage of Apex tests in a Salesforce org.

Accessing Apex Code Coverage Report

  1. Launch Metazoa Snapshot and connect to your Salesforce orgs.
  2. Right-click on any item in the connected Salesforce org.
  3. Select the “Apex Code Coverage Report” from the context menu.

Navigating the Apex Code Coverage Report

The report interface has multiple sections:

Apex Tests List

  • On the left-hand side, there is a list of all Apex tests in the connected Salesforce org.
  • Click on any test to view the classes it covers and the results of the test.
  • Use checkboxes next to each test to include specific tests in the display report.

Display Report

  • The Display Report section shows the selected tests and their results.
  • It provides an overall percentage of code coverage for the Salesforce org.
  • You can customize the report by color-coding based on coverage percentage levels.

Code Coverage Tab

  • This tab allows users to see which lines of code are covered by the tests and which are not.
  • Select a test from the list to see its code coverage details.
  • This is useful for identifying code coverage issues and analyzing the effectiveness of tests.

Schedule Report Tab

  • This tab allows users to schedule Apex Code Coverage reports.
  • Reports can be scheduled to run on a specific schedule or whenever there is a new snapshot.
  • Reports can be generated in CSV, HTML, or PDF formats.
  • The reports can be sent via email or posted to Chatter for a specific group of recipients.
  • There is an option to conditionally send reports based on coverage levels (e.g., only if the coverage is medium or low).

Integration with Deployment

Metazoa Snapshot allows users to integrate code coverage with the deployment process.

  • When metadata is being moved between Salesforce orgs, code coverage can be run as part of the deployment.
  • Users can select which tests to run as part of the deployment process.
  • This feature is accessed via the deployment arrow, which represents the movement of metadata from one Salesforce org to another.

Conclusion

The Metazoa Apex Code Coverage Report is an essential tool for Salesforce administrators and developers. It provides insights into the coverage levels of Apex tests and allows users to schedule and customize reports. This functionality is vital for ensuring code quality and meeting Salesforce’s code coverage requirements. Additionally, integrating code coverage into the deployment process helps in maintaining high standards during metadata migration.

Learn More!

Snapshot provides powerful tools for Salesforce Administrators that help manage the change and release process, visualize org complexity, improve security and compliance, and lower the total cost of Org ownership. Visit the AppExchange to start a 14 day free trial or click the button below to schedule a demo.

🎉 Congratulations! 🎉

You’ve successfully completed the Metazoa Metadata Studio Certification Class. With the skills you’ve acquired, you’re now adept at harnessing the power of Metazoa’s Metadata Studio, seamlessly integrating artificial intelligence into Salesforce org management. You have earned you a certificate! Well done, and we wish you continued success in your future endeavors!