Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the rationale behind the choice of specific kinds of coverage criterias when looking at an algorithm?

So, I am unsure of what are the pros and cons of du-path coverage (or for instance, any data flow coverage criteria) versus predicate criterias or branch/node criterias.

I can see that in certain cases there are clear advantages of one kind of coverage to the other. For instance, if a lot of my algorithm consists in something alike the next example

void m();
void n();

void method(boolean b) {
    if (b) {
        m();
    } else {
        n();
    }
}

it is clear that using any kind of data flow coverage criteria will let a lot of logic untested (which is something we'd like to avoid). Using for the given case a predicate/clause criteria would be way better.

Now, what I'd like to know is for the general case, what are the things you look for in an algorithm when deciding which kind of coverage criteria you'll follow, between

  • Graph
  • Data Flow
  • Logic
  • Input
  • Syntax

kinds of coverage criteria (basically, the ones found in Introduction to Software Testing). That is, I am basically looking for general heuristics to follow, for the general case.

Thanks

like image 665
devoured elysium Avatar asked Jun 11 '11 18:06

devoured elysium


People also ask

What is the purpose of code coverage?

Code coverage is a software testing metric that determines the number of lines of code that is successfully validated under a test procedure, which in turn, helps in analyzing how comprehensively a software is verified. Developing enterprise-grade software products is the ultimate goal of any software company.

What is coverage criteria in software testing?

Coverage criteria are adequacy measures to qualify if a test objective is satisfied when executing test cases on a system under test [4]. Coverage criteria are established to estimate the quality of test cases, and criteria combinations are considered in software testing [5].

Which is the test method satisfying the coverage criteria that each logical path through the program be tested?

Path testing is a structural testing method that involves using the source code of a program in order to find every possible executable path. It helps to determine all faults lying within a piece of code. This method is designed to execute all or selected path through a computer program.

What are the types of test coverage?

Two common forms of test coverage 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.


1 Answers

Admittedly, I've not done much research in this area and am not necessarily following you completely (mostly due to my lack of experience in this subject). But hopefully this is not too far off base.

My understanding of Code Coverage has always been that you want to cover every possible execution path. Now I know some paths are much more important than others (for example: the "happy path" is much more important than some obscure path to set some property), but regardless of weather or not you "cover" every path, you at least want to be aware of their existence and make somewhat of a conscious choice on what and what not to cover (via unit tests or manually).

You can start by eyeballing methods and writing testcases, but this quickly becomes unreliable since you're guaranteed NOT to see every possibly execution path no matter the algorithm type. Even very small programs will produce bugs that were unaccounted for since the tester failed to think of "trying it" that way.

What you really need is a Code Coverage tool to tell you which execution paths were covered by your unit-tests and which were not. At that point, you can make logical decisions on weather or not to cover those missing cases (since not all cases may not be worth your time). Without such a tool, I'd think you'd spend countless man hours going line by line and keeping track of what testcases covered what... Even if the tool costs several hundred dollars (or even several thousand dollars), I think you'd quickly recoup those funds in time saved.

So my general heuristic for you is to use such a tool to track your testing coverage and make decisions to cover or not to cover based on its results.

Some code coverage tools (not comprehensive):

  • .NET - NCover
  • PHP - PHPCoverage
  • JAVA - EMMA
  • Ruby - CoverMe
  • JavaScript - JSCoverage
like image 164
Brandon Boone Avatar answered Oct 20 '22 16:10

Brandon Boone