void ... (...)
{
...
if (...) GREEN
{
okPart (...); GREEN
}
else
{
errorPart (...); RED
throwXxx (...); RED
}
...
}
Here EMMA does not give any information, whether the else block has never been executed (because the if expression was allways true) or it has been executed (but "throwXxx" threw its exception).
What do you think about the idea, not only to instrument the block end, but also the block beginning, so that EMMA knows about blocks,
that have been "partially" covered.
Partially covered blocks should not be shown red nor green. They could be shown yellow or in some different colur (because partially covered blocks are not the same as fractionally covered lines).
And it should be possible to configure "emma report" how it should count partially covered blocks (e.g. as a percentage:
0% = count them as unvovered as it is done now, 100% = count them as covered,
or any percentage in between).
Of course EMMA cannot know how big the covered part of a partially covered block really is (otherwise it would be necessary to instrument every line or statement or even every byte code instruction).
A method or even class containing no fully covered block, but at least one partially covered block should be counted as covered (because even methods and classes containing only one little covered block and 1000 big uncovered blocks are counted as covered).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am sure that as soon as we start instrumenting basic block beginnings in addition to ends, some users will start asking that the middle points should also be instrumented.
Every single bytecode instruction in Java can be a source of thrown exceptions.
Let's face it, the only way to keep everybody happy is to add instrumentation *per each source code line*. Because otherwise you can always come up with an example where you know a line has been executed but EMMA still shows it as red.
I don't want to go this route. I might consider a compromise, where only block beginnings are instrumented if the user prefers that.
You either accept EMMA philosophy or not.
If you have a basic block that you know was executed then why worry about it? Are such blocks really responsible for a giant fraction of your code coverage? I find it extremely unlikely. EMMA is a tool to help you get from 50% coverage to something like 75% and stop there. Trying for 100% is inevitably a waste of time.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for your answer.
But I am not sure, whether I was able to express clearly, what I meant.
There are three kinds of lines.
(a) Surely covered lines (they are shown in green and counted as covered, o.k.)
(b) Surely not covered lines (they are shown in red and counted as not covered, o.k.)
(c) Possibly covered lines (they should be shown in another colour and counted according to the wishes of the user; but currently they are erroneously treated like b).
Your proposal "only block beginnings are instrumented if the user prefers that" would allow the user to decide, whether he wants (c) to be trated like (a) or (b).
This is surely better than the current solution.
So if (or as long as) you do not consider to treat (c) as an own case different from (a) and (b), then PLEASE implement your proposal.
Any idea, when your (or my) proposal could be implemented?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Example:
private void throwXxx (...) throws XxxException
{
trace (...);
...
throw new XxxException (...);
}
void ... (...)
{
...
if (...) GREEN
{
okPart (...); GREEN
}
else
{
errorPart (...); RED
throwXxx (...); RED
}
...
}
Here EMMA does not give any information, whether the else block has never been executed (because the if expression was allways true) or it has been executed (but "throwXxx" threw its exception).
What do you think about the idea, not only to instrument the block end, but also the block beginning, so that EMMA knows about blocks,
that have been "partially" covered.
Partially covered blocks should not be shown red nor green. They could be shown yellow or in some different colur (because partially covered blocks are not the same as fractionally covered lines).
And it should be possible to configure "emma report" how it should count partially covered blocks (e.g. as a percentage:
0% = count them as unvovered as it is done now, 100% = count them as covered,
or any percentage in between).
Of course EMMA cannot know how big the covered part of a partially covered block really is (otherwise it would be necessary to instrument every line or statement or even every byte code instruction).
A method or even class containing no fully covered block, but at least one partially covered block should be counted as covered (because even methods and classes containing only one little covered block and 1000 big uncovered blocks are counted as covered).
I am sure that as soon as we start instrumenting basic block beginnings in addition to ends, some users will start asking that the middle points should also be instrumented.
Every single bytecode instruction in Java can be a source of thrown exceptions.
Let's face it, the only way to keep everybody happy is to add instrumentation *per each source code line*. Because otherwise you can always come up with an example where you know a line has been executed but EMMA still shows it as red.
I don't want to go this route. I might consider a compromise, where only block beginnings are instrumented if the user prefers that.
You either accept EMMA philosophy or not.
If you have a basic block that you know was executed then why worry about it? Are such blocks really responsible for a giant fraction of your code coverage? I find it extremely unlikely. EMMA is a tool to help you get from 50% coverage to something like 75% and stop there. Trying for 100% is inevitably a waste of time.
Thank you for your answer.
But I am not sure, whether I was able to express clearly, what I meant.
There are three kinds of lines.
(a) Surely covered lines (they are shown in green and counted as covered, o.k.)
(b) Surely not covered lines (they are shown in red and counted as not covered, o.k.)
(c) Possibly covered lines (they should be shown in another colour and counted according to the wishes of the user; but currently they are erroneously treated like b).
Your proposal "only block beginnings are instrumented if the user prefers that" would allow the user to decide, whether he wants (c) to be trated like (a) or (b).
This is surely better than the current solution.
So if (or as long as) you do not consider to treat (c) as an own case different from (a) and (b), then PLEASE implement your proposal.
Any idea, when your (or my) proposal could be implemented?
I have now written a Feature Request for this (http://sourceforge.net/tracker/index.php?func=detail&aid=1092080&group_id=108932&atid=651900).