Michal Kordas
Michal Kordas

Reputation: 10925

Goal "cobertura:instrument" in Cobertura Maven Plugin

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?

Upvotes: 1

Views: 640

Answers (1)

Kraal
Kraal

Reputation: 2877

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.

Upvotes: 2

Related Questions