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.