Hi Serkan,
I think that there are many ways to define the coverage of tests. I
agree with your observation that many tests may be required to show
program correctness. In order for tests to show that code is bug free,
they would probably have to execute every possible path through the
program. The number of paths through a program is exponential in the
number of branches, so exploring all paths is often infeasible. For
many programs even exploring small fractions of the paths may be very
computationally expensive.
A simple example:
int myFunction(int x)
{
int result = 0;
if(x % 2 == 0)
{
// A (even)
result++;
}
else
{
// B (odd)
result--;
}
if(x % 3 == 0)
{
// C (divisible by 3)
result++;
}
else
{
// D (indivisible by 3)
result--;
}
return result;
}
We can test all the branches with the tests values 2,3,7.
2 – branches A,D
3 – branches B,C
7 – branches B,D
However, even with this simple code where there is 100% branch and
statement coverage, those tests do not cover the path “A,C”. An
additional test case is required. For example the value (x == 6) would
cover “A,C”.
To further complicate the picture, some programs are
non-deterministic. For example, programs that are multi-threaded may
have a very large number of different ways that the threads could be
scheduled - further increasing the number of test cases that would be
required to show program correctness. Furthermore, some programs (e.g.
a web server) are designed not to terminate, how long should we run
our tests for?
I think that when designing objects it is interesting to think about
modularity, encapsulation and compositionality. Can we design objects
such that when they are composed they are likely to retain whatever
nice properties they have - without us necessarily having to test all
the compositions?
Cheers,
Tim
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Growing Object-Oriented Software" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
growing-object-oriente...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.