Code coverage: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
en>Monkbot
en>Patlecat
m That code is not C++ but just plain C
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{refimprove|date=May 2009}}
For these who are trying to produce a wedding, a wedding reception, and a honeymoo...<br><br>Weddings can be each the most thrilling and stressful times of a person&quot;s life. Positive it is undoubtedly entertaining to design wedding invitations, plan your reception and choose colors for your ceremony and bridesmaid&quot;s dresses. On the flip side, the woes of budgeting for a wedding, hiring a minister, hiring a caterer, and securing entertainment can be just as stressful as the exciting parts can be enjoyable.<br><br>For these who are trying to create a wedding, a wedding reception, and a honeymoon on a restricted price range, there might be 1 option that you have not yet explored. Obtaining married on board a cruise ship is a classy but relatively [http://www.bbc.co.uk/search/?q=affordable+alternative affordable alternative] for your wedding. Most cruise lines carry their very own wedding planner who can place collectively an whole wedding, minister (or the cruise ship version of 1) reception, catering, and all. Learn more on this related wiki - Click here: [http://www.sdjintongyuan.com/showthread.php?tid=9817 visit]. Wedding planners, even for little weddings, can price upwards of a handful of thousand dollars but you can safe a low price, thoughtful and memorable wedding on board a luxury cruise liner for much less than a thousand dollars if you are fortunate. Visit this web site [http://ddthemesdemo.com/biosphere/members-2/komisduh2388145/activity/176391/ wedding caterers san diego] to study how to flirt with this activity. This is on best of the charges of traveling on the ship for the duration of the cruise as effectively. Of course this is not the most extravagant wedding, and clearly you get what you pay for so the more cash you place into your luxury cruise liner wedding, the fancier it will turn out to be.<br><br>Realistically, you would not expect all 50 to one hundred of your wedding guests to shell out thousands of dollars just to sail about the planet with you and your loved a single to celebrate your wedding with you, and of program the cruise lines do not count on that either. To get alternative viewpoints, please consider having a gaze at: [http://support.dubmenow.com/entries/48004515-Wedding-Organizing-101-Get-Ready-Get-Set-Get-Organized- team]. Several lines will permit your guests to come on board for your wedding and reception for a couple of hours. The liner organization may possibly pick for themselves or give you the solution of having your wedding on a docked ship and never ever have the cruise liner leave the area, or to sail about the port for the duration of the wedding. Most times the ship will never ever even leave the port throughout the wedding, as this can cause troubles with marriage licenses when it comes to what may or may possibly not be United States or international waters.<br><br>There are a lot of cruise lines that will give you a high quality, enjoyable wedding that will be really memorable for you and your loved one particular. Carnival Cruises, Princess Cruises, and the Disney Cruise line supply fun, romantic wedding packages at prices that truly are hard to beat, specifically when compared to the combined cost of a wedding, reception, and honeymoon completed the more standard way. Princess Cruises even offer you wedding packages that pamper the bride and groom prior to the wedding, and add little touches like stringed instruments, flowers, and candles to develop a ceremony that you, your loved one, and your guests will always look back on fondly..Le Parfait Paris<br>668 G Street<br>San Diego CA, 92101<br>1-619-245-4457<br><br>If you cherished this article and you simply would like to receive more info pertaining to [http://vulgardairy5185.yolasite.com health reports] [http://Data.Gov.uk/data/search?q=generously+visit generously visit] the web site.
 
In [[computer science]], '''code coverage''' is a measure used to describe the degree to which the [[source code]] of a [[computer program|program]] is tested by a particular [[test suite]]. A program with high code coverage has been more thoroughly tested and has a lower chance of containing [[software bug]]s than a program with low code coverage. Many different metrics can be used to calculate code coverage; some of the most basic are the percent of program [[subroutine]]s and the percent of program [[statement (computer science)|statements]] called during execution of the test suite.
 
Code coverage was among the first methods invented for systematic [[software testing]]. The first published reference was by Miller and Maloney in ''[[Communications of the ACM]]'' in 1963.<ref>{{cite journal
| author      = Joan C. Miller, Clifford J. Maloney
| title        = Systematic mistake analysis of digital computer programs
| journal      = [[Communications of the ACM]]
| volume      = 6
| issue        = 2
|date=February 1963
| publisher    = [[Association for Computing Machinery|ACM]]
| location    = New York, NY, USA
| issn        = 0001-0782
| pages        = 58&ndash;63
| doi          = 10.1145/366246.366248
}}</ref>
 
==Coverage criteria==
To measure what percentage of code has been exercised by a [[test suite]], one or more ''coverage criteria'' are used.
 
=== Basic coverage criteria ===
There are a number of coverage criteria, the main ones being:<ref>{{cite book | author=Glenford J. Myers | title=The Art of Software Testing, 2nd edition |publisher=Wiley | year=2004| isbn=0-471-46912-2}}</ref>
* '''Function coverage''' - Has each function (or [[subroutine]]) in the program been called?
* '''Statement coverage''' - Has each [[statement (computer science)|statement]] in the program been executed?
* '''Branch coverage''' - Has each branch of each control structure (such as in [[Conditional (programming)|''if'' and ''case'' statements]]) been executed?  For example, given an ''if'' statement, have both the true and false branches been executed?  Another way of saying this is, has every [[Graph theory|edge]] in the program been executed?
* '''Decision coverage''' - Has every point of entry and exit in the program been invoked at least once, and has every decision in the program taken on all possible outcomes at least once? (where a decision is a Boolean expression composed of conditions and zero or more Boolean operators)?  This definition is not the same as '''branch coverage''',<ref name ="Position Paper CAST10">Position Paper CAST-10 (June 2002). ''[http://www.faa.gov/aircraft/air_cert/design_approvals/air_software/cast/cast_papers/media/cast-10.pdf What is a “Decision” in Application of Modified Condition/Decision Coverage (MC/DC) and Decision Coverage (DC)?]''</ref> however, some do use the term ''decision coverage'' as a synonym for ''branch coverage''.<ref name="mathworks">MathWorks. ''[http://www.mathworks.com/help/slvnv/ug/types-of-model-coverage.html Types of Model Coverage.'']</ref>
* '''Condition coverage''' (or predicate coverage) - Has each Boolean sub-expression evaluated both to true and false?  This does not necessarily imply decision coverage.
* '''Condition/decision coverage''' - Have both decision and condition coverage been satisfied?
* '''State coverage''' - Has each state in a [[finite-state machine]] been reached and explored?
* '''Parameter Value Coverage''' - In a method taking parameters, have all the common values for such parameters been considered?
 
<br />
 
=== '''[http://www.rhyous.com/2012/05/08/unit-testing-with-parameter-value-coverage-pvc/ Parameter Value Coverage]''' ===
 
For example, consider the following C++ function:
<source lang="cpp">
int foo (int x, int y)
{
    int z = 0;
    if ((x>0) && (y>0))
    {
        z = x;
    }
    return z;
}
</source>
 
Assume this function is a part of some bigger program and this program was run with some test suite.
* If during this execution function 'foo' was called at least once, then ''function coverage'' for this function is satisfied.
* ''Statement coverage'' for this function will be satisfied if it was called e.g. as <code>foo(1,1)</code>, as in this case, every line in the function is executed including <code>z = x;</code>.
* Tests calling <code>foo(1,1)</code> and <code>foo(0,1)</code> will satisfy ''branch coverage'' because, in the first case, the 2 <code>if</code> conditions are met and <code>z = x;</code> is executed, while in the second case, the first condition <code>(x>0)</code> is not satisfied, which prevents executing <code>z = x;</code>.  Those calls also satisfy ''decision coverage'', since the only Boolean expressions in this program are the ''if'' condition which has taken all possible values.
* ''Condition coverage'' can be satisfied with tests that call <code>foo(1,1)</code>, <code>foo(1,0)</code> and <code>foo(0,0)</code>. These are necessary because in the first two cases, <code>(x>0)</code> evaluates to <code>true</code>, while in the third, it evaluates <code>false</code>. At the same time, the first case makes <code>(y>0)</code> <code>true</code>, while the second and third make it <code>false</code>.
* ''Parameter Value coverage'' (PVC) is the idea that all common possible values for a parameter are tested. For example, common values for a string are: 1) null, 2) empty, 3) whitespace (space, tabs, newline), 4) valid string, 5) invalid string, 6) single-byte string, 7) double-byte string. It may also be appropriate to use very long strings. Failure to test each possible parameter value may leave a bug. Testing only one of these could result in 100% code coverage as each line is covered, but as only one of seven options are tested, there is only 14.2% PVC.
 
Condition coverage does not necessarily imply decision coverage. For example, consider the following fragment of code:
<source lang="pascal">
if a and b then
</source>
Condition coverage can be satisfied by two tests:
* <code>a=true</code>, <code>b=false</code>
* <code>a=false</code>, <code>b=true</code>
However, this set of tests does not satisfy decision coverage since neither case will meet the <code>if</code> condition.
 
[[Fault injection]] may be necessary to ensure that all conditions and branches of [[exception handling]] code have adequate coverage during testing.
 
=== Modified condition/decision coverage ===
For [[safety-critical]] applications (e.g., for avionics software) it is often required that '''[[Modified Condition/Decision Coverage|modified condition/decision coverage (MC/DC)]]''' be satisfied. This criterion extends condition/decision criteria with requirements that each condition should affect the decision outcome independently. For example, consider the following code:
<source lang="pascal">
if (a or b) and c then
</source>
The condition/decision criteria will be satisfied by the following set of tests:
* a=true, b=true, c=true
* a=false, b=false, c=false
However, the above tests set will not satisfy modified condition/decision coverage, since in the first test, the value of 'b' and in the second test the value of 'c' would not influence the output. So, the following test set is needed to satisfy MC/DC:
* a='''false''', b='''false''', c=true
* a='''true''',  b=false, c='''true'''
* a=false, b='''true''',  c='''true'''
* a=false,  b=true,  c='''false'''
 
=== Multiple condition coverage ===
This criterion requires that all combinations of conditions inside each decision are tested. For example, the code fragment from the previous section will require eight tests:
* a=false, b=false, c=false
* a=false, b=false, c=true
* a=false, b=true, c=false
* a=false, b=true, c=true
* a=true, b=false, c=false
* a=true, b=false, c=true
* a=true, b=true, c=false
* a=true, b=true, c=true
 
=== Other coverage criteria ===
There are further coverage criteria, which are used less often:
* '''[[Linear Code Sequence and Jump]] (LCSAJ) coverage''' - has every LCSAJ been executed?
* '''JJ-Path coverage''' - have all jump to jump paths<ref name="On the relationship between two control-flow coverage criteria: all JJ-paths and MCDC">M. R. Woodward, M. A. Hennell, "On the relationship between two control-flow coverage criteria: all JJ-paths and MCDC", Information and Software Technology 48 (2006) pp. 433-440</ref> (aka LCSAJs) been executed?
* '''Path coverage''' - Has every possible route through a given part of the code been executed?
* '''Entry/exit coverage''' - Has every possible call and return of the function been executed?
* '''Loop coverage''' - Has every possible loop been executed zero times, once, and more than once?
 
[[Safety-critical]] applications are often required to demonstrate that testing achieves 100% of some form of code coverage.
 
Some of the coverage criteria above are connected. For instance, path coverage implies decision, statement and entry/exit coverage. Decision coverage implies statement coverage, because every statement is part of a branch.
 
Full path coverage, of the type described above, is usually impractical or impossible. Any module with a succession of <math>n</math> decisions in it can have up to <math>2^n</math> paths within it; loop constructs can result in an infinite number of paths. Many paths may also be infeasible, in that there is no input to the program under test that can cause that particular path to be executed.  However, a general-purpose algorithm for identifying infeasible paths has been proven to be impossible (such an algorithm could be used to solve the [[halting problem]]).<ref>Dorf, Richard C.: ''Computers, Software Engineering, and Digital Devices'', Chapter 12, pg. 15. CRC Press, 2006. ISBN 0-8493-7340-9, ISBN 978-0-8493-7340-4; via [http://books.google.com/books?id=jykvlTCoksMC&pg=PT386&lpg=PT386&dq=%22infeasible+path%22+%22halting+problem%22&source=web&ots=WUWz3qMPRv&sig=dSAjrLHBSZJcKWZfGa_IxYlfSNA&hl=en&sa=X&oi=book_result&resnum=1&ct=result Google Book Search]</ref> Methods for practical path coverage testing instead attempt to identify classes of code paths that differ only in the number of loop executions, and to achieve "basis path" coverage the tester must cover all the path classes.
 
==In practice==
The target software is built with special options or libraries and/or run under a special environment such that every function that is exercised (executed) in the program(s) is mapped back to the function points in the source code. This process allows developers and quality assurance personnel to look for parts of a system that are rarely or never accessed under normal conditions (error handling and the like) and helps reassure test engineers that the most important conditions (function points) have been tested. The resulting output is then analyzed to see what areas of code have not been exercised and the tests are updated to include these areas as necessary.  Combined with other code coverage methods, the aim is to develop a rigorous, yet manageable, set of regression tests.
 
In implementing code coverage policies within a software development environment, one must consider the following:
 
*  What are coverage requirements for the end product certification and if so what level of code coverage is required?  The typical level of rigor progression is as follows: Statement, Branch/Decision, [[Modified Condition/Decision Coverage]](MC/DC), LCSAJ ([[Linear Code Sequence and Jump]])
*  Will code coverage be measured against tests that verify requirements levied on the system under test ([[DO-178B]])?
*  Is the object code generated directly traceable to source code statements?  Certain certifications, (i.e. DO-178B Level A) require coverage at the assembly level if this is not the case: "Then, additional verification should be performed on the object code to establish the correctness of such generated code sequences" ([[DO-178B]]) para-6.4.4.2.<ref name="DO-178B" />
 
Test engineers can look at code coverage test results to help them devise test cases and input or configuration sets that will increase the code coverage over vital functions. Two common forms of code coverage used by testers are statement (or line) coverage and branch (or edge) coverage. Line coverage reports on the execution footprint of testing in terms of which lines of code were executed to complete the test. Edge coverage reports which branches or code decision points were executed to complete the test. They both report a coverage metric, measured as a percentage.  The meaning of this depends on what form(s) of code coverage have been used, as 67% branch coverage is more comprehensive than 67% statement coverage.
 
Generally, code coverage tools incur computation and logging in addition to the actual program thereby slowing down the application, so typically this analysis is not done in production.  As one might expect, there are classes of software that cannot be feasibly subjected to these coverage tests, though a degree of coverage mapping can be approximated through analysis rather than direct testing.
 
There are also some sorts of defects which are affected by such tools. In particular, some [[race condition]]s or similar [[Real-time computing|real time]] sensitive operations can be masked when run under code coverage environments; and conversely, and reliably, some of these defects may become easier to find as a result of the additional overhead of the testing code.
 
==Usage in industry==
Code coverage is one consideration in the safety certification of avionics equipment. The guidelines by which avionics gear is certified by the [[Federal Aviation Administration]] (FAA) is documented in [[DO-178B]]<ref name="DO-178B">RTCA/[[DO-178B]], ''Software Considerations in Airborne Systems and Equipment Certification, Radio Technical Commission for Aeronautics,'' December 1, 1992</ref> and the recently released [[DO-178C]].<ref name="DO-178C">RTCA/[[DO-178C]], ''Software Considerations in Airborne Systems and Equipment Certification, Radio Technical Commission for Aeronautics,'' January, 2012.</ref>
 
==See also==
{{portal|Software Testing}}
* [[Cyclomatic complexity]]
* [[Intelligent verification]]
* [[Linear Code Sequence and Jump]]
* [[Modified Condition/Decision Coverage]]
* [[Mutation testing]]
* [[Regression testing]]
* [[Software metric]]
* [[Static code analysis]]
* [[White box testing]]
 
==References==
{{reflist}}
 
 
{{DEFAULTSORT:Code Coverage}}
[[Category:Software testing]]
[[Category:Software metrics]]
[[Category:Software testing tools]]

Latest revision as of 11:47, 31 December 2014

For these who are trying to produce a wedding, a wedding reception, and a honeymoo...

Weddings can be each the most thrilling and stressful times of a person"s life. Positive it is undoubtedly entertaining to design wedding invitations, plan your reception and choose colors for your ceremony and bridesmaid"s dresses. On the flip side, the woes of budgeting for a wedding, hiring a minister, hiring a caterer, and securing entertainment can be just as stressful as the exciting parts can be enjoyable.

For these who are trying to create a wedding, a wedding reception, and a honeymoon on a restricted price range, there might be 1 option that you have not yet explored. Obtaining married on board a cruise ship is a classy but relatively affordable alternative for your wedding. Most cruise lines carry their very own wedding planner who can place collectively an whole wedding, minister (or the cruise ship version of 1) reception, catering, and all. Learn more on this related wiki - Click here: visit. Wedding planners, even for little weddings, can price upwards of a handful of thousand dollars but you can safe a low price, thoughtful and memorable wedding on board a luxury cruise liner for much less than a thousand dollars if you are fortunate. Visit this web site wedding caterers san diego to study how to flirt with this activity. This is on best of the charges of traveling on the ship for the duration of the cruise as effectively. Of course this is not the most extravagant wedding, and clearly you get what you pay for so the more cash you place into your luxury cruise liner wedding, the fancier it will turn out to be.

Realistically, you would not expect all 50 to one hundred of your wedding guests to shell out thousands of dollars just to sail about the planet with you and your loved a single to celebrate your wedding with you, and of program the cruise lines do not count on that either. To get alternative viewpoints, please consider having a gaze at: team. Several lines will permit your guests to come on board for your wedding and reception for a couple of hours. The liner organization may possibly pick for themselves or give you the solution of having your wedding on a docked ship and never ever have the cruise liner leave the area, or to sail about the port for the duration of the wedding. Most times the ship will never ever even leave the port throughout the wedding, as this can cause troubles with marriage licenses when it comes to what may or may possibly not be United States or international waters.

There are a lot of cruise lines that will give you a high quality, enjoyable wedding that will be really memorable for you and your loved one particular. Carnival Cruises, Princess Cruises, and the Disney Cruise line supply fun, romantic wedding packages at prices that truly are hard to beat, specifically when compared to the combined cost of a wedding, reception, and honeymoon completed the more standard way. Princess Cruises even offer you wedding packages that pamper the bride and groom prior to the wedding, and add little touches like stringed instruments, flowers, and candles to develop a ceremony that you, your loved one, and your guests will always look back on fondly..Le Parfait Paris
668 G Street
San Diego CA, 92101
1-619-245-4457

If you cherished this article and you simply would like to receive more info pertaining to health reports generously visit the web site.