1

What might be some real use case to invoke cobertura:instrument goal from Cobertura Maven Plugin?

I know that it just instruments classes, but when it may be preferred over cobertura:cobertura or cobertura:check?

Michal Kordas
  • 10,475
  • 7
  • 58
  • 103

1 Answers1

2

This goal can be needed for instance for integration tests. If I make a parallel with what I'm doing with qualinsight-mojo-cobertura-core (an alternative mojo to cobertura-maven-plugin), having a separate goal for instrumentation allows you to plug other actions between code instrumentation and coverage report generation.

For instance, if you take this pom.xml example, you'll see that:

  • instrument-it is done during the package phase (using qualinsight-mojo-cobertura-core),
  • jetty server is lanched during pre-integration-test phase,
  • it-tests are run during the integration-test phase,
  • jetty server is stopped during the post-integration-test phase (that's when the cobertura.ser file is written to disk) then
  • report-it-coverage is run during the verify phase.

Without having two separate goals for instrumentation and report generation, this would'nt be possible. Side note: cobertura:cobertura also executes tests, it's an all in one goal.

Kraal
  • 2,779
  • 1
  • 19
  • 36