I tried replacing the call to prop with this.@prop and this made no change to the cobertura results. Are others using cobertura with groovy and getting the branch coverage they expect?
Richard Lawrence
On Jan 3, 2008 6:53 PM, Guillaume Laforge <
glaforge@...> wrote:
Your two classes aren't equivalent.
In the case of Groovy, the assignment and the return value
respectively call the setter and getter which are automatically
created by the Groovy compiler. So that may be the reason why you see
some difference.
You could do this.@prop to be sure you deal with the field and not the
getter / setter to see whether it's exactly as your Java example.
On Jan 3, 2008 6:28 PM, Mythical Development
<
mythical.development@...> wrote:
> If I have the following Java class:
>
> public class LineCoverage {
>
> private String prop;
>
> public String execute() {
> prop = "SomeValue";
> return prop;
> }
> }
>
> and the following groovy test class:
>
> class LineCoverageTest extends GroovyTestCase {
>
>
> void testCoverage() {
>
> def lineCoverage = new LineCoverage()
> assert lineCoverage.execute() == "SomeValue"
> //assert lineCoverage.execute() == "SomeValue"
> }
>
> }
>
> I get cobertura test results with 100% line coverage and branch coverage of
> N/A
>
> If I change the java class to a groovy class:
>
> class LineCoverage {
>
> def prop
>
> String execute() {
> prop = "SomeValue"
> prop
> }
> }
>
> I get !00% line coverage and 1/2 branch coverage. Uncommenting the repeated
> line in the groovy test class gets me 2/2 branch coverage.
>
> Does anybody know why?
>
>
> Richard
--
Guillaume Laforge
Groovy Project Manager
G2One, Inc. Vice-President Technology
http://www.g2one.com
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email