Test-Driven Development

The last months I have tried to change my testing style from being too centered around using mock objects. Malte and I realized, after exploring mock objects, that this technique is too heavy to be used except in certain cases, such as when writing code against a remote server.

I find that the style I’ve come to use is more focused on the interface of the classes than the internals, which is good. I don’t care if a class has or has not a test class, as long as it’s covered by tests I’ve written.

Different parts of the code are covered by different tests. For trivial code, it’s okay if it’s tested indirectly by one or many test cases. But for more non-trivial code, it should be clear which the test case or cases are that test it. That is, for non-trivial code, the tests should be at the same level as, or at least close to the code. For more trivial code, the test cases can be at a higher level than the code.

I don’t know if this came out intelligible or not. Perhaps I will elaborate on it later.

The above was posted to my personal weblog on April 25, 2002. My name is Peter Lindberg and I am a thirtysomething software developer and dad living in Stockholm, Sweden. Here, you’ll find posts in English and Swedish about whatever happens to interest me for the moment.


Related posts:

Posted around the same time:

The seven most recent posts:

  1. Tesugen Replaced (October 7)
  2. My Year of MacBook Troubles (May 16)
  3. Tesugen Turns Five (March 21)
  4. Gustaf Nordenskiöld om keramik kontra kläddesign (December 10, 2006)
  5. Se till att ha två buffertar för oförutsedda utgifter (October 30, 2006)
  6. Bra tips för den som vill börja fondspara (October 7, 2006)
  7. Light-Hearted Parenting Tips (September 16, 2006)