In my office I have a picture of Step 1 of a Lego build. I don’t actually remember what it was to, but it fascinated me in its simplicity. Because no matter how hard of a Lego model you are going to build, you have to start with a single piece, and connect another piece to it. And I loved that Lego didn’t start with this connection, but instead a single Lego. One step. One Lego.
This idea of a single step is what drives my passion around Test-Driven Development. You don’t know where to start? Write a test. But even then, writer’s block kicks in, and you don’t know what test to write. So go back to the Lego. Write the simplest thing that could possibly work:
it 'should pass the test' do 1.should eq 2 end
and run it
➜ ruby rspec F Failures: 1) My tests should pass the test Failure/Error: 1.should eq 2 expected: 2 got: 1 (compared using ==) # ./spec/my_spec.rb:5:in `block (2 levels) in <top (required)>' Finished in 0.00133 seconds 1 example, 1 failure Failed examples: rspec ./spec/my_spec.rb:4 # My tests should pass the test
Now make it pass and see green. Your test system is set up. Now you aren’t trying to start something, but merely add to it.
So don’t be overwhelmed by first steps. Start simple. Add to it. And from there, amazing things can happen.
(Millennium Falcon picture courtesy of http://www.flickr.com/photos/stickkim/6966161674. Blog title courtesy of Alistair Cockburn)
1. Lego instructions are AMAZING.
2. I agree – always start with a failing test (i do true == false for a deeply philosophical moment) – make sure the basic wires are in place before putting anything complicated in place.