Jacoco and Arquillian in a multi module Maven project

百般思念 提交于 2020-01-24 20:04:39

问题


I am following this article: http://www.softwarepassion.com/it-coverage-with-arquillian-jacoco-extension/ to get test coverage for arquillian integration tests. My project is a multi module though and I don't know where to put the plug in and dependencies. Is it in the top pom, the artifact-making module or in the integration test module? Thank you


回答1:


To some extent it depends on the details of your Maven setup, which aren't in your question. Here is some general advice.

1) Where should you put the arquillian-jacoco and jacoco dependencies?

These dependencies should probably go wherever the rest of your Arquillian dependencies are. My understanding is that it is simply having these dependencies that triggers Arquillian to use JaCoCo, not the plugin declaration; even if these dependencies are in a parent of the POM with the actual Arquillian tests, the Arquillian test classes should still be instrumented. You wouldn't put these dependencies in a sibling module to the module with the tests though as they need to be inherited by the integration test module (unless this sibling module has been declared as a dependency of the test module of course).

2) Where should you put the JaCoCo plugin declaration?

As noted above, you may not even need this declaration, depending on what you are trying to achieve. If you want to generate a report, rather than just the jacoco.exec files, then you will need to declare the plugin and an execution with the report goal. You may also want to declare the plugin with the prepare-agent goal if you have other tests that you wish to be instrumented with JaCoCo, such as unit tests.

If you are going to declare the plugin, it can be treated the same way as any other Maven plugin. If you want to run JaCoCo across multiple modules by default you could choose to put the plugin declaration in your parent POM within the regular 'plugins' tag and have it inherited by all child modules, or you may wish to put it in the parent POM within the 'pluginManagement' element so the configuration can be inherited (see http://maven.apache.org/pom.html#Plugin_Management). Alternatively, if you only want to run Arquillian tests in your integration test module, you could also simply declare the plugin in this module's POM (given that you want a report, and without the prepare-agent goal if you're only instrumenting Arquillian tests).

Hope that helps!



来源:https://stackoverflow.com/questions/12354669/jacoco-and-arquillian-in-a-multi-module-maven-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!