« Return to Thread: Cobertura line coverage with groovy class

Cobertura line coverage with groovy class

by Mythical Development :: Rate this Message:

Reply to Author | View in Thread

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

 « Return to Thread: Cobertura line coverage with groovy class