Martin Fowler said about JUnit: "Never in the field of software development have so many owed so much to so few lines of code." (Introduction to xUnit Test Patterns)
Others have also said it's something any reasonable programmer could produce in a weekend.
So apparently, writing a unit testing framework is no big deal, because the hard thinking has already been done, thanks to Kent Beck and others.
After devoting much time to listening to podcasts, reading about unit testing, and asking around a bit, I finally came round to having a go at writing a little unit testing framework for VDF. It is loosely based on NUnit, learning from Pragmatic Unit Testing in C# with NUnit.
Thanks to my employer, Emma EDB AS, I'm allowed to share the code with you. It is very much a work in progress, and I'm open to suggestions and criticism.
Open the "VDFUnit Testrunner Sample" workspace in VDF 15.0, and run the "VDFUnit TestRunner" project to try the sample tests provided. Currently, the Testrunner is set to run the tests automatically, so you don't have to push the "Run Tests!" button unless you want to run them again. The text box lists all the cTestfixture objects that are created in oVDFUnitTests.pkg, and turns green when the tests have been run successfully (or red if errors occurred).
A few obvious features are planned:
Still, I believe VDFUnit can be used in its current form as a starting point for writing unit tests in VDF. The enclosed Zip file is made for VDF15, but it should work in VDF 12 and 14 as well.
- Test categories, allowing sets of tests to be run at different times (e.g. slower-running "integration tests")
- Non-GUI testrunner for automatic testing and logging (e.g. to be hosted on a Continuous Integration server).
- More Assert messages
As a side note, you may be interested in the implementation of an iterator interface included in there as well.
To learn more about unit testing, I particularly recommend checking out books, blogs, interviews, podcasts, and presentations by Kent Beck, Robert C. Martin, Michael Feathers, and Kevlin Henney.
So feel free to check out the testing framework. All feedback is appreciated!