From: Devin Mullins Date: 2005-06-08T22:56:52+09:00 Subject: Re: Test-Driven Development in GUIs TDDing UI is hard, because it's a side-effect, rather than a return value or a parameter. I don't know the half of it. Nor, for that matter, know how to use Tk. I present to you a "Hello world" example. require 'test/unit' class Greeter def self.greet puts 'Hello, world!' end end class MockGreeter < Greeter class << self attr_reader :out def puts(*args) @out = @out ? [] : args end end end class TestGreeter < Test::Unit::TestCase def testGreet MockGreeter.greet assert_equal ['Hello, world!'], MockGreeter.out end end Subclass and override puts. Dependency injection doesn't help here. You can have greet take a Module as a parameter, and call module.puts, but you still need to test the container, and make sure it's passing Kernel to the greet method. Sorry, that's the short version. I gotta go. Devin