Phone

Contact sales: +1 (833) 441 7687

View your Apex code coverage line by line in Gearset

Sam Williams on February 12th 2021


An important principle of software development is making sure your tests dig into all the deepest recesses of your code. After all, a mistake could creep into any line - and if a bug only gets triggered by an edge case, it won't surface for a long time. When it finally does emerge, it'll be harder to fix because you won't remember that part of your codebase.

We've recently released a new feature that lets you view your code coverage not just class by class, but also line by line.

Dig deep into your Apex code coverage with Gearset

Code coverage by class

Having tests in place that give you good coverage means you'll run into fewer headaches further down the road, which is why Salesforce requires a minimum 75% Apex code coverage to deploy to production.

Unit testing jobs in Gearset automatically run tests daily and show you the Apex code coverage for each of your classes. At a glance, you can see which of your classes have low coverage and are most at risk of containing bugs. Every time Gearset runs one of your tests, the coverage data is recorded. This gives you the ability to track the coverage history for each class, see what progress has been made, and identify where more work still needs to be done.

To see your code coverage results, navigate to the unit testing dashboard in Gearset and click the View history button. From the Test run history page, click View results to access all the details of any given completed test run.

Test run history page in Gearset

The Code coverage tab shows you the test details for each of your Apex classes, including their individual code coverage. To find specific classes quickly, you can filter by modification date as well as the class or trigger name.

View your Apex code coverage results by class

Line-by-line code coverage

At the bottom of the Code coverage tab, you'll see a preview of the line-by-line coverage. This is useful when you need to take a quick peek at a specific function or block of code. To take a more detailed look at the entire file, expand the preview pane by clicking the window icon to the right of Next >.

See your Apex code coverage line by line

The larger window view makes it easier to see which parts of your Apex code are covered by tests and which ones aren't. By looking through the classes, you can quickly build up a list of the key methods most in need of more code coverage to make sure they're functioning correctly. Once you know which lines of code to tackle, it's just a matter of adding new test methods to check that these lines work as intended.

Want to dig into your Apex code coverage?

All our Enterprise users can now view their line-by-line code coverage. If you're currently on Gearset's Pro tier and would like to try out our Enterprise features, just give us a shout and we'll get you set up. If you're new to Gearset, starting a free trial gives you access to every part of the app. Let us know if you have questions about any of our features in the live chat on this page or in the app. We'd love to hear your feedback!

Get Gearset's newsletter for all the latest on Salesforce DevOps

Ready to get started with Gearset?

  • Free 30-day trial
  • No credit card required
  • Nothing to install in your orgs
Start free trial
  • Free 30-day trial
  • No credit card required
  • Nothing to install in your orgs