function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFBenSFBen 

Bug in Apex Test Execution and Apex Code Coverage

Recently I've been attempting to reduce test methods so that deployments are quicker by first identifying duplicate test methods, deleting them and rerunning test methods to check the code coverage.  Unfortunately I seem to be hitting a problem where rerunning the test methods shows no change in the code coverage - I found this quite odd as I thought there would be a few percentage increase/decreases (tested with classes that I knew would have less coverage and still no change).  

 

If I clear out the test history and rerun the tests all is fine so it seems to be a problem with Salesforce storing the percentage coverage for tests but not updating this when tests are rerun.  I've had different results when running all tests and running individual classes as well.  When looking at this problem I've mostly been looking at the code coverage at the bottom of a test execution, but noticed occurences when looking at the code coverage on the list of apex classes.  As mentioned clearing out the test history solves the issue but I think there shouldn't be an issue at all - rerunning tests should replace the code coverage from the previous test run.