« Fovea | Main | QOTD »

Test First

Google Testing Blog: TotT: Better Stubbing in Python

def Foo(path, **kwargs):
   if path_checker(path):
     return DoSomething()
     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


Post a comment

(you may use HTML tags for style)

Remember Me?

Trackback Pings

TrackBack URL for this entry: