Strong opinions, weakly held

Against TDD orthodoxy

Google developer Cedric Beaust argues that treating orthodox Test Driven Development as some kind of panacea is a mistake, a position that I find it difficult to argue with. In fact, I find myself rejecting nearly all dogmatic software development philosophies. I like to read about them, but in the end I just steal the parts that work for me and do what seems to make the most sense.

My dirty secret: I almost never write a test, watch it fail, and then fill in the code necessary to make the test pass. That seems gratuitous to me.


  1. I recently starting trying to do the tests first. I don’t write all the tests first, assuming that you know everything you need testing is like assuming you’re going to bang out a class in one fell swoop of coding, but there’s some obvious things that you know you will need.

    It had seemed gratuitous to me as well, but I figured I’d give it a try. The thing that I never realized before was that writing the test first lets you (and I apologize for the awkward phrasing) write the code you want to be able to write with your class.

    It’s very optimistic code, very clean and pretty and perfect and it’s the test is almost certainly going to change after some time spent with the actual object, but for a brief shining moment you get to pretend you have this perfect resource that you’re working with.

    And every time you change the real interface of the class you’re coding you have to justify it against that ideal.

    I have had sort of a “write some code, write some tests, write some code” kind of cycle, and I’m going to be continuing that cycle except after about a week or so of trying the tests first, that cycle is a “write some tests, write some code, write some tests” sort of thing.

  2. I definitely think that it has its place. Writing tests first is a kind of design, it enables you to think clearly about how you want the interface to your code to look, and how to structure your code so that you can actually test the aspects of it that need testing.

  3. I agree that TDD is not the development silver bullet as it doesn’t equate to quality. Tests are code. Code has bugs. Tests have bugs.

Leave a Reply

Your email address will not be published.


© 2024 rc3.org

Theme by Anders NorenUp ↑