How coverage report is calculated if same code executed as twice

Sivaraj November 19, 2015

Team,  I am executing the same package files twice. For example my package contains 10 files. I am running sanity and basic test cases against 10 java instrumented files. If I run alone sanity I am getting 25% and run alone basic test case I am getting 25%. In a single shot I am running both sanity + basic test case. Now the code  coverage percentage will be 50% or 25%(because same code is running again). I am getting only 25% code coverage. Can you please give your input why it is giving 25%? 

 

Thanks in Advance.

2 answers

1 accepted

1 vote
Answer accepted
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 19, 2015

Are your sanity and basic tests are not mutually exclusive? In other words do they test entirely different parts of your application classes? I'm asking because tests usually overlap each other, thus the summary coverage is usually less than sum of coverage from individual tests.

If you see no difference in coverage after running both sanity and basic tests, then there are two possibilities:

  • you ran tests incorrectly, for instance you have accidentally deleted coverage files from one of tests
  • your sanity and basic tests do not differ at all, i.e. they test exactly the same functionality.

 

When you ran sanity and basic tests together and generated an HTML report - do you see both sanity and basic test cases on the "Test results" tab? Do you see both sanity and basic test classes on the "Test code" tab?

 

1 vote
Grzegorz Lewandowski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 19, 2015

Code coverage is an metric saying that how much of your code is covered by tests. It doesn't matter how many times with how many tests you'll cover one line of you code base, it's still binary metric for that single line (covered or not). The percentage Clover is calculating is basically saying  # lines covered# lines in your instrumented code base

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events