Recently I was discussing with some friends if everyone should learn to code and one friend said “I think everyone should learn to write unit tests.” I was reading Nick Hodges’ Coding In Delphi book (available free when you buy XE5) in the chapter on Unit Tests and my son asked me about it. In trying to explain it to him, my son was convinced it was a great idea and wanted to know why everyone didn’t do unit testing. Good question.
This month, for our RAD-In-Action webinar series we have Nick Hodges talking about Unit Testing in Delphi. If you sign up to attend the event you get a copy of the chapter on unit testing from Nick’s book. It is a good one.
This is sure to be a great event, and I highly recommend everyone makes time for it. In preparation for the event I thought I would list out some Delphi Unit Testing tools. These are covered in Nick’s book, but I’ll add my commentary here:
- DUnit: The original unit testing framework for Delphi. It still ships with Delphi, and still works great.
- DUnit2: A fork of the original DUnit this is an alternative unit testing framework that is enhanced to work with the language features introduced in Delphi 2009.
- DUnitX: There are a lot of new language features in Delphi since DUnit was created. DUnitX is a whole new unit testing framework that takes advantage of these new language features to do some really cool things. MVP Robert Love has an excellent blog post about some of the cool things you can do with DUnitX and his plans and contributions.
- Delphi Code Coverage: Curious how much of your code is covered by unit tests? This tool answers that question for you. There is a wizard that goes with it to integrate it into the IDE.
- Delphi Mocks: One of the tricks with unit testing is to separate dependencies, but if your code depends on a database or network socket, how do you test it by itself? Enter Mocks. A brilliant tool to let you test the independent units of code without dependencies.
One side not about unit testing is you actually don’t need to use a framework, you just need to do it. Maybe there is another framework or tool you use, or you’ve developed your own in-house methodology. I’d love to hear about it, and I hope you join us Wednesday for Nick’s webinar, and bring your questions. I’ve got a few myself.