Imagine a multi-module Maven project, for example the following:
parent
+- core
+- main
maindepends on the module core.
Now I will write a class CoreClassin coreusing 2 methods: method1()and method2(). In tests, coreI write a test class that will test only CoreClass.method1().
If I run the coverage tool (in my case, Cobertura, using mvn sonar:sonar), I found that I get 50% test coverage on CoreClass(if we imagine that both methods are the same length).
So far, everything is in order.
Now, in the project main, I am writing a test class that will test CoreClass.method2(). Therefore, I usually expect 100% line coverage on CoreClasswhen I started the analysis of the entire project.
However, I still get 50% .
I understand that this is a comprehensive behavior. Indeed, Cobertura will be a tool CoreClassfor analyzing coverage only during tests in the module core, not on main. This explains why I still have 50% code coverage.
However, my question is to find out if there is a way to get real code coverage CoreClasswhen I run tests in all of my modules.
Thank!
ps: , main core. , , : o)
: Java 1.6, JUnit 4.8.1, Maven 2.0.9 ( 2.2.1, , ), Sonar 2.8