Term Paper: ON Analysis and Comparison of Statement Coverage of C and C++ Code
Term Paper: ON Analysis and Comparison of Statement Coverage of C and C++ Code
Term Paper: ON Analysis and Comparison of Statement Coverage of C and C++ Code
ON
Analysis and Comparison of Statement
coverage of C and C++ Code
Example:
Read A
Read B
If A>B
Else
Endif
Statement coverage=5/7*100=71%
This is purely a white box testing method. It tests the software’s internal
coding and infrastructure and so the programmer is the one who should take
the initiative to do this. This technique is very suitable for drupal
programmers and other programmers.
Different test cases may be derived to exercise the loop once, twice and
many times. This may be done regardless of the functionality of the
software.
Testing can reveal a fault Defect only when the execution of that
corresponding faulty element causes a failure. For example, if there is a
fault in the statement at line 10 of the source code, it could be revealed by
the test cases which has potential test steps or test data to reveal the
defect in the source code statement.
Generally in any software, if we look at the source code there will be a wide
variety of elements included in operators, functions, looping, exceptional
handlers and etc. But given a set of instruction to perform a task. All the
possible path's, line and statement with respect to the task should be
covered.
Advantages and Disadvantages
ADVANTAGES:
DISADVANTAGES
To achieve 100% statement coverage of this code segment just one test
case is required, one which ensures that variable A contains a value that is
greater than the value of variable Y, for example, X = 12 and Y = 10. Note
that here we are doing structural test design first, since we are choosing our
input values in order ensure statement coverage.
Since we have covered five out of six statements, we have 83% statement
coverage (with three tests). What test would we need in order to cover
statement 5, the one statement that we haven’t exercised yet? How about
this one:
This time the value of Z is 70, so we will print ‘Large Z’ and we will have
exercised all six of the statements, so now statement coverage = 100%.
Notice that we measured coverage first, and then designed a test to cover
the statement that we had not yet covered.
Note that Test 1_4 on its own is more effective which helps in achieving
100% statement coverage, than the first three tests together. Just taking Test
1_4 on its own is also more efficient than the set of four tests, since it has
used only one test instead of four. Being more effective and more efficient is
the mark of a good test technique.
Pros Of Statement Coverage
The main advantages of Statement Coverage are as mentioned below:
The higher this number, the better you exercise your code.
And you can satisfy it to different degrees and the degrees to which it’s
satisfied is measured by this value.
1.begin
2.int x, z;
3.input(x);
4.if(x<0)
5.x=-x;
6.z=foo-1(x);
7.output(z);
8.end
There should have been an else clause for x³0 before this statement.
Conclusion
Statement Coverage identifies those statements in any given method that
have been executed. By doing so it is able to recognize those chunks or
blocks of code that failed to perform their designated task. Ultimately,
identification of these blockages is the main job of Statement Coverage.
The higher the Statement Coverage number the better is the quality of the
written code. The best part of this testing technique is that it can be
conducted by the code developers themselves and that to continuously as
each subsequent statement is written.
References:
1. https://www.zyxware.com/articles/4161/what-is-statement-
coverage-in-testing.
2. https://www.guru99.com/learn-statement-coverage.html
3.istqbexamcertification.com/what-is-statement-coverage-
advantages-and-disadvantages/
4. https://www.zyxware.com/articles/4161/what-is-statement-
coverage-in-testing
5. www.testingbrain.com/whitebox/statement-coverage.html
6. www.softwaretestingmentor.com/line-coverage/