MessiandNeymar

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Monday, July 16, 2012

Java code coverage and thrown exceptions

Posted on 7:17 AM by Unknown

Recently, I've been working with various Java code coverage tools, such as Emma and JaCoCo.

Generally, these tools are quite powerful and sophisticated.

However, I recently learned of a rather fundamental limitation: they only measure a block as "covered" if that block terminates normally; if the block of code terminates due to a thrown exception, the block is not marked as covered.

The Emma documentation discusses exceptions in sections 2.5, 2.6, and 2.7 of the FAQ:

Thus, EMMA does not attempt to track the success or failure of every single bytecode instruction: instead, it marks a basic block covered when the control reaches its last instruction. A covered basic block is thus guaranteed to have executed without failures at least once in a given coverage run session.

...

the motivation behind this has been that most legitimate code is written so that methods return normally (without throwing an exception).

I'm sure I wasn't the only person unaware of this limitation.

There doesn't appear to be a way around this. So, for the time being, just because your Emma or JaCoCo coverage report indicates that a particular block of code is uncovered, you can't immediately conclude that it isn't invoked at all.

It might have been invoked, but terminated due to a thrown exception.

How is this situation handled in other code coverage tools, for other languages in which exceptions are a first-class part of the language?

Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Shelter
    I meant to post this as part of my article on Watership Down , but then totally forgot: Shelter In Shelter you experience the wild as a moth...
  • Parbuckling
    The enormous project to right and remove the remains of the Costa Concordia is now well underway. There's some nice reporting on the NP...
  • The Legend of 1900: a very short review
    Fifteen years late, we stumbled across The Legend of 1900 . I suspect that 1900 is the sort of movie that many people despise, and a few peo...
  • A Very Short Review of The Hangman's Daughter
    By way of the quite-nice Kindle Owners Lending Library , I recently read Oliver Potzsch's The Hangman's Daughter . At least part of ...
  • Jones v Anand
    If you think grandmaster chess is boring, with lots of positional strategic maneuvering, you owe it to yourself to play through the game bet...
  • A Glorious Defeat: a very short review
    Somewhat unexpectedly, Timothy Henderson's A Glorious Defeat: Mexico and Its War with the United States found its way to my nightstand....
  • Unbroken: a very short review
    Laura Hillenbrand's Seabiscuit: Three Men and a Racehorse was a massive worldwide hit, and became a movie hit as well. It took her seve...
  • One Day: a very short review
    I'm about two years late (typical), but I finally got around to David Nicholls's One Day . The book's concept is to tell a story...
  • Rim fire winding down
    I hadn't been over to Inciweb's Rim Fire status page in a while, so I dropped in to see how the progress goes. This is the long, sl...
  • XCOM Enemy Unknown
    I don't have much time to play video games, so I tend to go many months between games, looking for just the right one. I've been pla...

Blog Archive

  • ►  2013 (165)
    • ►  September (14)
    • ►  August (19)
    • ►  July (16)
    • ►  June (17)
    • ►  May (17)
    • ►  April (18)
    • ►  March (24)
    • ►  February (19)
    • ►  January (21)
  • ▼  2012 (335)
    • ►  December (23)
    • ►  November (30)
    • ►  October (33)
    • ►  September (34)
    • ►  August (29)
    • ▼  July (39)
      • Serious infrastructure issues
      • Drone pilots in the NYT
      • Nice Olympics sailing video
      • Inside the Coursera contract
      • Networking: theory and practice
      • The other Eagle
      • Precious Reynolds and the Milwaukee Protocol
      • Trying to understand the evolution of finance
      • Who invented the Internet, part 94
      • Annie Hall, now and then
      • Simple hardware lessons for a software guy, part 3
      • Simple hardware lessons for a software guy, part 2
      • Simple hardware lessons for a simple software guy
      • The bubble is back!
      • It's not just a game ...
      • Random stuff I'm reading currently
      • Solomon's Oak: a very short review
      • Postcards from the high end...
      • Some Dallas phone numbers are not Dallas phone num...
      • Perforce 2012.2 has entered beta testing
      • Good enough for GitHub
      • The Coursera Tsunami
      • A collection of AWS post-mortems
      • Java code coverage and thrown exceptions
      • Google Summer of Code and the University of Moratuwa
      • Construction Everywhere
      • MMDS 2012
      • Tips for security conference week
      • GSoC 2012: halfway there!
      • Various database topics
      • A troubling article on scientific careers
      • ubuntu tracker and locate
      • So that's what it takes to find a Higgs Boson!
      • And now we will know for sure
      • Silicon Valley craziness
      • Matthew Yglesias on patent "reform"
      • Post-vacation link dump
      • A week in Kauai
      • I'm back online
    • ►  June (27)
    • ►  May (48)
    • ►  April (32)
    • ►  March (30)
    • ►  February (10)
Powered by Blogger.

About Me

Unknown
View my complete profile