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...
  • 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...
  • Rediscovering Watership Down
    As a child, I was a precocious and voracious reader. In my early teens, ravenous and impatient, I raced through Richard Adams's Watershi...
  • Must be a heck of a rainstorm in Donetsk
    During today's Euro 2012 match between Ukraine and France, the game was suspended due to weather conditions, which is a quite rare occur...
  • Beethoven and Jonathan Biss
    I'm really enjoying the latest Coursera class that I'm taking: Exploring Beethoven’s Piano Sonatas . This course takes an inside-out...
  • Starting today, the games count
    In honor of the occasion: The Autumn Wind is a pirate, Blustering in from sea, With a rollocking song, he sweeps along, Swaggering boisterou...
  • 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...
  • For your weekend reading
    I don't want you to be bored this weekend, so I thought I'd pass along some articles you might find interesting. If not, hopefully y...
  • Are some algorithms simply too hard to implement correctly?
    I recently got around to reading a rather old paper: McKusick and Ganger: Soft Updates: A Technique for Eliminating Most Synchronous Writes ...
  • Don't see me!
    When she was young, and she had done something she was embarrassed by or felt guilty about, my daughter would sometimes hold up her hand to ...

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