« Fovea | Main | QOTD »

Test First

Google Testing Blog: TotT: Better Stubbing in Python

def Foo(path, **kwargs):
   if path_checker(path):
     return DoSomething()
   else:
     return DoSomethingElse()

This looks like a throw back to #ifdef. The problem with this approach is that instrumenting methods to do something based on the caller's context makes for context dependent code. It also makes it harder to read, which is no small concern. Reasoning about code that depends on something other than its inputs is arguably the operational meaning of 'complexity' in software. I'm not sure we want to be promoting one best practice, testing, via some other worst practices. "I'm in the test context" seems like a problem where attributes or aspect annotation would be more appropriate solution.


March 10, 2007 05:32 PM

Comments

Post a comment

(you may use HTML tags for style)




Remember Me?

Trackback Pings

TrackBack URL for this entry:
http://www.dehora.net/mt/mt-tb.cgi/2053