Incorrect Explanation of "line coverage" in coveragemeter

Source: Internet
Author: User

In the previous discussion on code coverage, we have already talked about the defects of line coverage. However, row coverage is still widely used because it is simple enough. What surprised me is that as a commercial C ++CodeCoveragemeter, a coverage tool that explicitly states that row-based data overwrites are not provided because they think row-based data overwrites are inaccurate.

The original text is as follows:

Coveragemeter does not support line coverage because this kind of measurement and statistic is not accurate.

This metric depends on how you format the code

 

Then, four methods of writing the same piece of code are listed, and the line coverage results are very different.

The first method is line coverage.33%

Int Main ()
{
Hit If ( True ) Return   1 ;
MIS Foo ();
MIS Return   0 ;
}

 

Method 2: line coverage50%

Int Main ()
{
Hit If ( True )
Hit Return   1 ;
MIS Foo ();
MIS Return   0 ;
}

 

Method 3: line coverage66%

  Int Main ()
{
Hit If ( True )
Hit Return   1 ;
MIS Foo (); Return   0 ;
}

 

Method 4: line coverage100%

Int Main ()
{
Hit If ( True ) Return   1 ; Foo (); Return   0 ;
}

 

In fact, there are many methods to prove that row coverage is not allowed. The above method is only one of them. Some people may refute the reasons mentioned above, because they think their Code complies with certain code specifications, it is absolutely not allowed to write multiple statements in the same row. Yes, that's right. You can prove that the above reasons are insufficient, but cannot overturn its conclusion.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.