1

Has anyone been successful using JUnit's Enclosed runner with the cobertura maven plugin? I've looked at the plugin documentation and some searching but I've been unable to determine how to configure the plugin to recognize tests in static nested classes

I have a test class defined something like

@RunWith(Enclosed.class)
public class SomeTestClass {

    public static class Testing {

        @Test
        public void testMethod() {

        }
    }
}

Both running JUnit from Eclipse and mvn test (I use the surefire maven plugin) run all my tests without issue however the cobertura maven plugin doesn't seem to recognize them and I'm left with 0 code coverage in the reports. My Cobertura maven plugin configuration is

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>2.5</version>
    <executions>
        <execution>
            <id>site</id>
            <phase>pre-site</phase>
            <goals>
                <goal>clean</goal>
            </goals>
        </execution>
        <execution>
            <id>instrument</id>
            <phase>site</phase>
            <goals>
                <goal>instrument</goal>
                <goal>cobertura</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <check>
            <branchRate>85</branchRate>
            <lineRate>85</lineRate>
            <haltOnFailure>false</haltOnFailure>
            <totalBranchRate>85</totalBranchRate>
            <totalLineRate>85</totalLineRate>
            <packageLineRate>85</packageLineRate>
            <packageBranchRate>85</packageBranchRate>
        </check>
        <encoding>UTF-8</encoding>
        <formats>
            <format>html</format>
            <format>xml</format>
        </formats>
    </configuration>
</plugin> 
Sean Carroll
  • 2,651
  • 2
  • 24
  • 21

0 Answers0