How Apex Code Coverage Works
September 28, 2021•103 words
An often misunderstood aspect of Salesforce development is how the code coverage numbers are calculated. Here's a throwback article the Salesforce Developer blog that explains the calculation in detail and how it can be different than the result you get when deploying.
https://developer.salesforce.com/blogs/developer-relations/2012/11/how-code-coverage-works
Note to self: If you want to make sure you're getting a more pure result of code coverage (especially the lines covered) from the specific tests you're running right now, make sure to enable "Store Only Aggregated Code Coverage" (Setup -> Apex Test Execution -> Options)
This resets the test results data every time a new test run is executed.