Wednesday 24 April 2013

Setting up TDD on a Mac with iTerm2 and vim

In order to get anywhere with TDD, it is vital to set up your development environment so that re-running tests is either automatic, or requires only a single keypress.

Here's how I have things set up...

I'm a big fan of vim, and since I'm working on my macbook my choice of terminals is rather limited.  Fortunately I can use the fantastic iTerm2.

Here's my setup for development:


Here I have iTerm2 and vim both set up using the solarized colour scheme.  This is not only easy on the eye for day to day development, but since it has both a "dark" and a "light" version I can toggle between them if I need to and I always use the "light" version if I am demonstrating something in a presentation.

Here's the same arrangement using the "dark" version.


I have split the iTerm2 window to give me a space in which to run the unit tests.  Then vim running in the top window is also running in split-window mode to enable me to see the test and the code at the same time.

The key thing for me is that when I write a file in vim, the unit tests are re-run automatically.  There are no extra buttons to press at all.

To achieve this I have installed a little python script called rerun; this helpfully monitors the filesystem and runs a command whenever any file changes.  It ignores revision control files by default, and other files can be excluded.

iTerm2 can also be run in full screen mode, which hides the dock and the menu bar to maximize your screen real-estate.

No comments:

Post a Comment