| «« Code Coverage | Tweaks Ahoy! »» |
|
About
I'm Ryan Lowe, a Software Engineering graduate living in Ottawa, Canada. I like agile software development and Ruby on Rails.
I write this blog in Canadian English and don't use a spell checker. Typos happen.
Projects
» Full-time Ruby on Rails freelancer
» Full-time with Rails since May 2005 » Former committer for RadRails (now Aptana) » I also have a few Rails side-projects in development: 1. wheretogoinTO.com Toronto nightlife 2. Hey Heads Up! TODO list and sharing 3. Layered Genealogy family history research 4. foos for foosball scoring 5. fanconcert for music fans (on hold) Hiring Rails developers? I can telecommute by the hour from Ottawa, Canada »» Email: rails AT ryanlowe DOT ca
BulletBlog
Now hosted on Hey! Heads Up -- check it out!
Syndication
Pings
Recent
Derek Lowe's (Ryan's older brother) words at Ryan's funeral
blog@ryanlowe.ca no more Forging Email Headers: Good, Bad or Ugly? Sarcastic Dictionary (Part 1 of Many) Tags Hierarchies Twisting Rails is Risky Business Risky Business? My Take on Early Alphas Whoa, it's August 2007 Closing Comments A Postscript to "Growth at the grassroots" »» All Blog Posts
Linkage
del.icio.us/ryanlowe
technorati/ryanlowe.ca/blog Aurora Roy Jim Andrew Trasker Travis Kibbee Karen Dr. Unk Ayana Van Bloggers Joel Spolsky Robert Scoble Tim Bray Dave Winer Raymond Chen James Robertson Ruby/Rails Bloggers rubyonrails.org weblog David Heinemeier Hansson Dave Thomas James Duncan Davidson Mike Clark Jamis Buck Signal vs. Noise Tobias Luetke Amy Hoy: (24)slash7 Jeremy Voorhis Eclipse Bloggers Planet Eclipse EclipseZone Luis de la Rosa Eclipse Foundation Kim Horne Billy Biggs Ian Skerrett Mike Milinkovich Bjorn Freeman-Benson Denis Roy
Archives
|
Coverage Isn't a Silver Bullet
Don't get me wrong -- I like code coverage. You just have to understand what you're looking at. Code coverage tells you what lines of program code that your tests hit. It doesn't tell you that you have perfect software when your tests run 100% green and you have 100% coverage. All that means is that your tests cover what's been implemented. Often bugs include what hasn't been implemented. Have you covered error possibility 14 in your code? Is feature ABC in the codebase yet? These are easy questions to answer if you know how to read the tests ... but that is difficult. Compounding this problem is that your test's intentions may be correct but the test implementation could be wrong. Don't think that only your program code has bugs in it -- your tests do too. However, you could always just test your tests and test your test's tests .... etc. (please don't do this, I'm kidding) Good tests and program code are like two playing cards resting against each other: if either are wrong the test still fails. Sometimes though you get a situation where a bug is symmetrical on both sides and the test passes anyway. These tests can give you a false sense of security and are usually only found when someone else tries to use the API in a real life situation or during a code/test audit. Tests that have poor asserts can also give you a false sense of security. Say you have a function that returns an array: Widget[] getWidgets(int parameter). If you are testing on a known set of Widgets in your unit test, you'll expect a specific array to be returned by this function. Someone may write the test assertEquals(3, getWidgets(42).length); and it will pass. But what were the three widgets? Were they the right three widgets? Were they in the correct order? Do we care about order? Relaxed testing like this can result in really hard to find bugs when someone else comes along and trusts the getWidgets() method too much. I'm finding that unit tests are really hard to manage. Not only is it difficult to discover the intent of the test, but also what part of the program code it actually exercises. But we put up with these disadvantages because having tests that we have to figure out is still better than having no tests at all. However, it would be nice if I could go one method at a time in an IDE like Eclipse and see in one perspective:
So that would be nice. Anyone want to write me an Eclipse plugin? Posted at June 25, 2003 at 06:48 PM ESTLast updated June 25, 2003 at 06:48 PM EST Comments
|