I´m working on a unit tester for c++, mostly for practice, but I´m stuck.
The way I want it to work is as follows:
- It reads all class and function names from all .hpp files within a defined test folder and its sub-folders. These have assertions that are linked to a logger that outputs HTML files with the test results.
- It creates a single .hpp or .cpp file that creates one instance of every test class and runs every function in it.
- It compiles the .hpp/.cpp file created in step 2.
- It runs the output of step 3.
I have 1. and 2. down but I´m having trouble compiling the .hpp file I created. I initially wanted to compile using a simple call to cl.exe but that is proving to be more problematic than I originally anticipated.
Do any of you know of a good/simple way of compiling a single file?
I have done some research on make/nmake but I can´t figure out how to accomplish this with them.
Also, if this method of doing unit tests is completely stupid, please let me know.
Some info:
I´m using Windows 7 64-bit and Visual Studio 2010
Assuming the generated
something.cppfile contains#include "something.hpp", then it should just be a case ofcl something.cppand you get asomething.exe, which you can run in some suitable way.“Calling every funciton on an object” seems a little strange – how do you know whether the result is correct? If we have a complex object, it may require more than creation to support calling all functions. What parameters are you passing in to each function? How do you know what it should return?