Hi,
I was discussing an interesting thing about coverage. Scenario is this:
We have two ways of testing code.
1. Some scripts
2. Junit tests
The scripts execute some java test classes ( not conforming to the junit
framework) and we can claculate the coverage.
Junit tests are executed and on the same set of files but testing other
parts of the code.
So lets say coverage is 30 % for 1 and 40 % for 2. It is not true to say
that we have 70% code coverage on that file. Since the tests can test
the same parts of the code. Is there a way to make sure that code is
tested only once even if we use two different ways of testing? And is it
possible to get fair measurement?
All hints and experience in this matter is very welcome!
cheers,
//mikael
Oliver Wong - 10 Nov 2005 20:42 GMT
> Hi,
>
[quoted text clipped - 17 lines]
>
> All hints and experience in this matter is very welcome!
How did you determine that the coverage was 30% for 1 in the first
place?
- Oliver
"." - 11 Nov 2005 00:09 GMT
> Hi,
>
[quoted text clipped - 17 lines]
>
> All hints and experience in this matter is very welcome!
My experience with code coverage is to use a coverage tool. Something like
JProbe can be used to determine what you test cases have covered. You
instrument the application with the coverage tool, run your scripts/jUnit
tests. It will then tell what was executed and how many times. Without
something like JProbe I'm not sure how you would do it.

Signature
Send e-mail to: darrell dot grainger at utoronto dot ca
Ingo R. Homann - 11 Nov 2005 09:06 GMT
Hi,
I can suggest the code-coverage tool emma/emmajava. It sometimes is a
bit difficult to setup, but it is worth the setup-trouble, because it
gives you really great code-coverage statistics.
Note however, that code-coverage (measured in percentage of
lines/blocks/methods executed) is not a perfect kind of measurement. e.g.:
String sql="SELECT * FROM "
if(t1) {
sql+="table1";
}
if(t2) {
sql+="table2";
}
execute(sql);
If you execute two tests on that code, one with t1==true and t2==false
and one test with t1==false and t2==true, the code is covered to 100%.
But of course that does not mean that the code is correct. If you would
do a third test with t1==false and t2==false, it would fail!
Note that (AFAIK) there does not exist any tool that can sensefully deal
with this problem.
Ciao,
Ingo
Monique Y. Mudama - 11 Nov 2005 18:26 GMT
> Hi,
>
[quoted text clipped - 22 lines]
> Note that (AFAIK) there does not exist any tool that can sensefully deal
> with this problem.
Code coverage isn't sufficient to test code, but I do think it's a
good first step.

Signature
monique
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html