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

Code Coverage and ApexTestExecution or RunAllTests


There is a lot of confusion regarding the code coverage calculations for me, please help me understand how to get proper code coverage and test results.

I have been using some of the options available in related to running unit tests.please suggest the correct approach.


1)If i clear the test history and use apex test execution ,will it update the code coverages of all classes ,
For some classes the code coverage is displayed as 0% and when i click on the "0%" link it shows some code coverage and when the class view page is refreshed it shows a different number.

Can we use apex test execution to calculate code coverage? 


2) when i run all tests it clears the test history and runs all the tests.Is the code coverage calculations accurate when i use this ?


3)A clear code coverage on setup->apex classes page , it is not deleting the test history but is clearing the code coverage. when should we use this ?


4)There is link on setup->apex classes page "Calculate organization wide code coverage" when should we use this ?


Please provide your comments .