Configuring method context filters

Still need help?

The Atlassian Community is here for you.

Ask the community

You can filter-out less important code sections using context filters for: methods (groovy+java), statements (java) and code blocks (java). See Using Coverage Contexts for more details.

A report can use custom set of columns - see <clover-report> / <columns> tag documentation.

 

Example:

setuptask = { ant, binding, plugin ->
    ant.'clover-setup'(initstring: "target/clover/db/clover.db") {
      ant.fileset(dir: "grails-app") { }
      ant.fileset(dir: "src/groovy") { }
      ant.fileset(dir: "src/java") { }
      ant.fileset(dir: "test") { }

      // Ignore private constructors in Groovy - using normalized constructor signature
      ant.methodContext(name: 'private-constructors', regexp: 'private void <init>\\(\\)') { }

      // Ignore logging statements. Note that statement context is currently supported only for Java.
      ant.statementContext(name: 'log',   regexp: '^log\\..*')
      ant.statementContext(name: 'if-log', regexp: '^if.*\\(log\\..*')
    }
}

reporttask = { ant, binding, plugin ->
    ant.'clover-report'(initstring: "target/clover/db/clover.db") {
      ant.current(outfile: "target/clover/html-report", title: "API Report") {
        // NOTE: you have to add the 'filter' attribute with a list of filters from clover-setup task
        ant.format(type: "html", filter: "private-constructors,log,if-log") { }
        ant.fileset(dir: "grails-app") { }
        ant.fileset(dir: "src/groovy") { }
        ant.fileset(dir: "src/java") { }
        ant.fileset(dir: "test") { }
        ant.columns {
          lineCount()
          filteredElements()
          uncoveredElements()
          totalPercentageCovered()
        }
      }
    }
}
Last modified on Aug 11, 2014

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.