Exploration Through Example

Example-driven development, Agile testing, context-driven testing, Agile programming, Ruby, and other things of interest to Brian Marick
191.8 167.2 186.2 183.6 184.0 183.2 184.6

Wed, 31 Aug 2005

Pacific Northwest Software Quality Conference

I've long had affection for PNSQC. It's a regional conference, but the only evidence of that is its size. The content is more like what you'd expect from a national conference. It's in Portland, Oregon, which is a little bit of a hotbed of Agile: Ward Cunningham, Jim Shore, Rebecca Wirfs-Brock, Steven Newton - all these people are Portland locals (though I suppose Ward may be completely gone now). Of the six keynote and invited speakers, four are pretty firmly associated with Agile: Mike Cohn, Esther Derby, Linda Rising, and me.

They have a PDF brochure.

October tenth through the twelfth.

## Posted at 16:39 in category /conferences [permalink] [top]

Static typing, again

Sometimes when demoing Ruby, I get the reaction that runtime typing is too error-prone. I'm not alone in responding by saying that unit tests will catch the bugs a static typechecker would, plus others. So why use both?

That's something of a flip response, and it's not really true. Here's an example I stumbled over while working on a chapter of Scripting for Testers.

Here's code that sets a variable:

start_date = month_before(Time.now)

Here's one of the methods that consume it:

def svn_log(subsystem, start_date)
  credentials = "--username notme --password not-the-real-one"
  timespan = "--revision 'HEAD:{#{start_date}}'"
  root = "https://svn.pragprog.com/Bookshelf/titles/BMSFT/Book/code/"

  `svn log #{credentials} #{timespan} #{root}/#{subsystem}`
end

Here's how I called that method in a test:

svn_log('inventory', '2005-08-01')

The test passed. All the methods were tested, and all the tests passed. But the program failed:

$ ruby churn.rb
subversion/clients/cmdline/main.c:832: (apr_err=205000)
svn: Syntax error in revision argument 'HEAD:{Wed Aug 03 12:51:38 CDT 2005}'
subversion/clients/cmdline/main.c:832: (apr_err=205000)
svn: Syntax error in revision argument 'HEAD:{Wed Aug 03 12:51:38 CDT 2005}'
Changes since 2005-08-03:
inventory (-1)
churn (-1)

The problem is that I unit-tested svn_log with a string in the format Subversion expects, but month_before returns a Ruby Time object. When svn_log gets one of those, it formats it into the wrong format, which makes Subversion complain.

The root cause of the bug was my cretinous choice of a variable name. I should not have named a variable expected to contain a Time with the name "date", especially not when the idea "date" is part of the usage domain. Nevertheless, static typing would have caught it while dynamic typing did not.

However, it seems to me that such errors will be caught if the whole-system tests exercise every call in the app. Suppose you're doing TDD starting from business-facing tests. Every call in the app would have to be traceable to a test whose failure motivated (perhaps very indirectly) that call, therefore every call in the app would be exercised by the complete suite (modulo some smallish background rate of human coding/design error), therefore there is no need for typechecking. But I'm perhaps being too flip.

P.S. Reviewers of Scripting: the example has been slightly tweaked for this posting.

## Posted at 16:17 in category /agile [permalink] [top]

About Brian Marick
I consult mainly on Agile software development, with a special focus on how testing fits in.

Contact me here: marick@exampler.com.

 

Syndication

 

Agile Testing Directions
Introduction
Tests and examples
Technology-facing programmer support
Business-facing team support
Business-facing product critiques
Technology-facing product critiques
Testers on agile projects
Postscript

Permalink to this list

 

Working your way out of the automated GUI testing tarpit
  1. Three ways of writing the same test
  2. A test should deduce its setup path
  3. Convert the suite one failure at a time
  4. You should be able to get to any page in one step
  5. Extract fast tests about single pages
  6. Link checking without clicking on links
  7. Workflow tests remain GUI tests
Permalink to this list

 

Design-Driven Test-Driven Design
Creating a test
Making it (barely) run
Views and presenters appear
Hooking up the real GUI

 

Popular Articles
A roadmap for testing on an agile project: When consulting on testing in Agile projects, I like to call this plan "what I'm biased toward."

Tacit knowledge: Experts often have no theory of their work. They simply perform skillfully.

Process and personality: Every article on methodology implicitly begins "Let's talk about me."

 

Related Weblogs

Wayne Allen
James Bach
Laurent Bossavit
William Caputo
Mike Clark
Rachel Davies
Esther Derby
Michael Feathers
Developer Testing
Chad Fowler
Martin Fowler
Alan Francis
Elisabeth Hendrickson
Grig Gheorghiu
Andy Hunt
Ben Hyde
Ron Jeffries
Jonathan Kohl
Dave Liebreich
Jeff Patton
Bret Pettichord
Hiring Johanna Rothman
Managing Johanna Rothman
Kevin Rutherford
Christian Sepulveda
James Shore
Jeff Sutherland
Pragmatic Dave Thomas
Glenn Vanderburg
Greg Vaughn
Eugene Wallingford
Jim Weirich

 

Where to Find Me


Software Practice Advancement

 

Archives
All of 2006
All of 2005
All of 2004
All of 2003

 

Join!

Agile Alliance Logo