I've started playing with "Unit Testing". I use UnitTest++ as my unit testing framework after reading the excellent Unit Testing framework evaluation by Noel Llopis, I figured he must know what features you need, and I'm very happy with the framework so far.
Anyway, when I'm setting up a project for unit testing I've found I'm most comfortable with the following setup:
In the MyApplication project I put everything related to the actual application this could be a GUI application like an MFC app, then there's alot of code that's not the actual logic. In this project I link to my Libraries implementing the logic. In this case MyLibrary1. Then I have MyTestApplication that is the standalone application that is actually doing the unit testing. This application links with the UnitTest++ library and also the libraries implementing the logic, again, in this example, it's MyLibrary1.lib.
Now, the purpose of this post was to point out one of the more important details here. In MyTestApplication I have configured it to run the application itself as a Post-Build Event, like this:
This runs the application after a successful build and outputs any failed tests as clickable errors. This is the ultimate cool, never forget this! It will produce output similar to this:
In the MyApplication project I put everything related to the actual application this could be a GUI application like an MFC app, then there's alot of code that's not the actual logic. In this project I link to my Libraries implementing the logic. In this case MyLibrary1. Then I have MyTestApplication that is the standalone application that is actually doing the unit testing. This application links with the UnitTest++ library and also the libraries implementing the logic, again, in this example, it's MyLibrary1.lib.
Now, the purpose of this post was to point out one of the more important details here. In MyTestApplication I have configured it to run the application itself as a Post-Build Event, like this:
This runs the application after a successful build and outputs any failed tests as clickable errors. This is the ultimate cool, never forget this! It will produce output similar to this:
Leave a comment