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 4616806
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:02:07+00:00 2026-05-22T02:02:07+00:00

I am using cobertura first time. Everything works fine but what I wonder is,

  • 0

I am using cobertura first time. Everything works fine but what I wonder is,
there are lines in my code, which should never be called like:

try {
    em.persist();
}catch(Exception) {
    logger.error("can not create");
}

I am doing all controls until persist line, when my code works fine, error line never be reached and now it is so. Because of it I never have %100 line coverage.

Should I somehow suppress it?

Thanks, Bilal

  • 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-22T02:02:08+00:00Added an answer on May 22, 2026 at 2:02 am

    While you can exclude entire classes from your Cobertura coverage reports, you cannot exclude specific lines or methods.

    You should accept that 100% coverage is impossible to achieve in real-life projects, since there will always be unreachable code or code that can only be reached by simulating a complex combination of conditions.

    As other answers suggest, you can try and increase the unit test coverage by mocking/stubbing an EntityManager to throw an exception on persist. But this is pretty much as far as you can go.

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

Sidebar

Related Questions

Using CI for the first time and i'm smashing my head with this seemingly
I'm using maven-cobertura-plugin in order to calculate code coverage in my project. As I
In my project I need to create Cobertura Code Coverage report from Hudson using
I'm using the maven cobertura plugin to generate coverage reports, but for some reason,
I'm using SpringSecurity plugin in my project and also Cobertura plugin for code coverage
Using Sinatra and DataMapper. This is my first time trying to use more than
I am using Ivy for dependency managment. I have problems with maven-findbgs-plugin:plugin:1.3.1 maven-cobertura-plugin:plugin:1.3 There
I am using Maven site:run to generate a cobertura code coverage... The following is
Using Django, how do I generate the value of a field the first time
Is it possible using Cobertura to tell it to ignore certain bits of code

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.