6096 comments
2357 subscribers
6253 on Twitter
Subscribe! Feed reader E-mail

Test-driven development and happiness

Me: Happiness is a test suite that passes.
@philiph: Do you practice test-driven development for your happiness?
Me: Why, yes, actually, I do. It gives me a tangible sense of accomplishment and minimizes my mouse-clicking. =)

Developers find their own balance of how much project structure works with them. Some people like seat-of-their-pants coding. Others want detailed architecture diagrams. Me, I’m getting the hang of agile development practices, and I really enjoy using them.

Test-driven development, for example. Yes, I could just plunge ahead and write Drupal code, and I could test it by clicking on buttons and typing into forms. I don’t particularly like using the mouse or doing repetitive actions, so I write tests for functionality and occasionally for web interaction. Tests also mean that  I can check small pieces of functionality before I have to build a web interface. And when something breaks – not if, but when – tests help me narrow down the error.

It’s so satisfying to see the tests pass, too.

There are tests that exercise functionality, and tests that set up test data just the way we like it so that we can demonstrate features or try things out using the web interface. One of my team members showed me a wonderful technique for repeatable, well-structured test data by using a spreadsheet to generate PHP code. I’ve been extending the pattern for other things.

Drupal + Simpletest is awesome. It can’t handle everything, but it makes my Drupal life better. Happy developers write happy code!

Short URL: http://sachachua.com/blog/p/21968
  • http://www.darklingwood.com Tommy

    “Happy developers write happy code!”

    This has to be one of the Four Noble Truths of software development.

  • http://iis.drupalgardens.com Ben

    You can use excel to write SQL also! It’s the best trick anyone ever showed me.

On This Day...

  • 2012: Tips for growing as a sketchnoter — New to sketchnoting? Aside from reading Mike Rohde’s The Sketchnote Handbook (see my sketchnote of it!) and Dan Roam’s Back [...]
  • 2011: Weekly review: Week ending December 16, 2011 — From last week’s plans Work [X] Follow up on possible next engagements – got next Drupal project lined up, [...]
  • 2009: Learning plan for 2010 — Here are my priorities for 2010: Share as much as I can at work and in life. I want to share [...]
  • 2008: Leavin’ well enough alone — So I’ve gotten my Linux partition mostly back into working order. I had run out of hard disk space on [...]
  • 2008: #hohoto conversations — I put “Sacha Chua, @sachac, livinganawesomelife.com” on my nametag because putting “Sacha Chua, @sachac, sachachua.com” felt a bit repetitive. It [...]
  • 2007: Rethinking II — It’s funny, but the On This Day widget on my personal blog tells me that precisely three years ago, I [...]
  • 2007: Rethinking — There’s nothing like a commute to make me think existentially. ;) The 1.5 hour commute up to and 1.5 hour [...]
  • 2007: The Tick
  • 2004: Philippine OSS news: NCC eGov Center for Excellence — From JJ Disini: The NCC launched its eGov Center for Excellence on Monday. Maybe I’m wrong but I think this is a [...]
  • 2004: Linux advocacy: not just preaching to the choir — Graphical user interfaces have their advantages and disadvantages. While they present information in an easy-to-understand manner and make it easier for new [...]
  • 2004: The uses of darou: だろう — In writing, 本当のだろうか is preferred over 本当ですか. のでしょうか is the polite form. Other uses of darou 1. 推測 (guess, conjecture) だろう でしょう 2. 疑問 (question) のでしょうか のだろうか 3. 原因、理由の推測 のでしょう のだろう 4. [...]
  • 2004: Summarizing reading 8-2-1 — 若者の日本語力が低下していること。きちんとした言葉を使う機会が減れば減 るほど、言語能力は低下するという原因。国語という日本語を積極的に勉強し なければならないということ。 Tip: For summaries, end sentences with nouns like こと or 原因.
  • 2004: Kanji of the day — 1`Webブラウザから要求を受信すると、wwwサーバーはそれに対応する情報を送り返します。 Webブラウザからようきゅうをじゅしんすると、wwwサーバーはそれにたいおうするじょうほうをおくりかえします。 送り返します。| [It] sends [it] back. 情報を送り返します。| [It] sends back information. 対応する情報を送り返します。| [It] sends back the corresponding information. それに対応する情報を送り返します。| [It] sends back the information [...]
  • 2004: On the virtues of idleness — Read Quitting the Paint Factory and reflect a bit on the space we should create in our lives. =)
  • 2003: Revised sacha/perl-training/suck-data-in — (defun sacha/perl-training/suck-data-in () "Insert BBDB records for all the Perl trainees." (interactive) (goto-char (point-min)) (while (re-search-forward [...]
  • 2003: Elisp code to insert all — Data is of the form number|Name|e-mail|Expectations (defun sacha/perl-training/suck-data-in () "Insert BBDB records for all the Perl trainees." (interactive) (goto-char [...]
  • 2003: Extracting the trainees’ files and packaging them — Shell scripting to the rescue! # Zip their work up for DIR in *; do ( cd $DIR; zip perl-day1.zip * ); [...]
  • 2003: Extracting all the mail addresses from the programs — grep -ri 'mail' * -A 10 -B 10 | less This displays enough context information around the data so that I [...]
  • 2003: Project ideas — Rating system – they’ve got this already
  • 2003: Perl focus — - Reading source code, testing, adapting software to their own needs - 4 programmers
  • 2003: Stuff at [[../learn/perl/training/day1]] so far — Oh no, it’s 12:05 and I haven’t even started on Real Text Processing… Teaching.Perl

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging

Free sample!