0

I am having multiple test classes for one apex class .

If I run one test class it gives overall coverage for the apex class as 50% . By running other test class it drops down to 30 %. My basic doubt is about this calculation .How is the overall test coverage calculated for the apex class .Does it takes average of all the test classes run ? Also what about the methods which are common in different test classes .

Thanks in advance

6

Nor average, neither sum of percents. If some test methods cover one line of code twice, it only means that this exact line of code is covered.

So the actual test coverage is linesCovered / allLines * 100.

Example: imagine 1st test class covers one method in your controller (30%), 2nd test class covers 2 methods including the previous mentioned one (50%), if you run both classes you'll get 50% again, because number of covered lines will not increase.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.