Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6602761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:54:54+00:00 2026-05-25T18:54:54+00:00

Imagine a multi-modules Maven project, such as the following one: parent +- core +-

  • 0

Imagine a multi-modules Maven project, such as the following one:

parent
  +- core
  +- main

main is dependent on the core module.

I now write a class CoreClass in core, with 2 methods: method1() and method2().
In core tests, I write a test class that will only test CoreClass.method1().

If I run a coverage tool (in my case Cobertura, using mvn sonar:sonar), I will find that I get 50% of test coverage on CoreClass (if we imagine that both methods have the same length).

Until now, everything is ok.

Now, in main project, I write a test class that will test the CoreClass.method2(). So normally, I would expect to have 100% of line coverage on CoreClass when I run an analysis on the whole project.

However, I still get my 50%.

I understand that this is a comprehensive behavior. Indeed, Cobertura will instrument CoreClass for coverage analysis only during the tests execution on the core module, and not on the main.
That explains why I still have 50% of code coverage.

However, my question is to know if there is a way to get the real code coverage of CoreClass when I am running the tests on all of my modules.

Thanks!

ps: I know that in a perfect world, it is not the concern of the main module to test the core classes. But as you may know, we are not in a perfect world :o)

Technical information: Java 1.6, JUnit 4.8.1, Maven 2.0.9 (will be upgraded to 2.2.1 soon, but I don’t think it does really matter), Sonar 2.8

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:54:54+00:00Added an answer on May 25, 2026 at 6:54 pm

    Use jacoco and sonar and have a single jacoco.exec file result for all modules.
    Sonar will use this file and report the correct coverage for each module.
    I have use it for a multi module project successfully with Sonar

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a multi-module project documented with the (excellent) Sphinx. Our setup is not
Imagine you are utilizing Parallelism in a multi-core system. Is it not completely possible
I’m working on a multi dimensions array but i have a problem Imagine I
Imagine we have a program trying to write to a particular file, but failing.
Imagine I have an function which goes through one million/billion strings and checks smth
So imagine I'm building a Multi User Dungeon system using a MVC web application.
imagine I write a library in C. Further, imagine this library to be used
2 databases QF AND TK QF has the following: Imagine you have a table
I'm trying to write an editor overtop a multi-threaded game engine. In theory, through
I'm investigating a possible research topic for a thesis project that involves a multi-objective

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.