Unit testing C++ code (using Python?)

I'm about to start a medium sized project using C++ throughout.  I want to use unit testing to verify that certain things work / fail as expected, but I wondered about the methodologies used (I've used unit testing in other environments, but never with C++).

My project will be split into libs, and of course I can link to the libs and call functions from there, but the GUI is projected to be contained in an exe which links to the other libs - how would I call the functions in there?  Can I link to the exe (forgive the ignorance :-)

Also, do I have to use C++ as the testing language?  I've recently used Python for a couple of things, and would like to use that, since I feel it would be quicker to write these kinds of tests in that language.  It should be possible, because I know we can link them together, but will it be easier?  Has anyone tried it?

Finally, what frameworks do people use for this?  I'd prefer free, because I could have difficulty persuading my employer to spend money on this - I'm already expecting a job on my hands getting them to agree to unit testing (and automated builds, a decent bug tracking database, code reviews etc.)

I should point out that what I'm currently considering is use of either the Boost Test Library or CppUnit, if the testing must be done in C++, or PyUnit if I can use Python.  Other suggestions are of course welcome! Sadly, I've not seen any mention of people using PyUnit for C++ projects anywhere, so I guess it might not be wise...

Thanks for your help!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I take it that you want to write your exe in python and then create test librarie/s (dll's) that your python exe can use with C++?

Out of curiosity are you looking for more speed? I am wondering why C++?

Anyway,  I was looking for game programming languages and I believe I recall Python was able to accept C++ routines. I believe you could mix.

Then if that is truley the case the best way to create dll's (the easy way) is to use _declspec(dllexport)

With _declspec(dllexport) all you have to do is create a .h file that declares what you want in your library and then a .cpp file that defines it.

Then in your Python application you simply include the .h file which allows you access to the functions in your test unit library.

I like it cause it's much simpler to use than creating a def file with exports statement etc...

// in .h file you declare the function

#ifndef Test_h
#define Test_h

_declspec(dllexport) int Test(int In);


// in .cpp file you define the function

#include "test.h"

_declspec(dllexport) int Test(int In)
if(In<10)return 1;
return 0;

// Then use it in your python program

#include "test.h"

IainHereAuthor Commented:
Sorry, I obviously managed to describe that really badly :-(

The exe is also in C++ (because we're using the Stingray Toolkit - we need to interoperate with Excel and look pretty, with smart graphs etc).  The libs (they'll not be dlls, because we're compiling them all into the final exe) are also in C++ for several reasons - speed (complicated calculations), it's what the programmers know - actually, I don't know why we're doing the database connection in C++.  Consistency and knowing what you face, I guess.  Eg - what happens to a thrown exception when it travels through Python code to get back into a C++ lib?  How well do Python compilers work on Windows?  And then link into a VC++ project?  Note that those questions are not the subject of this one - I'm just explaining why we're not using other languages.  The difficult things will benefit from being done in C++, and the easy things are easy anyway.

Anyway, it was just the testing code I was thinking of putting in Python, since I know that they can be linked easily enough.  I was hoping for other people's experience of unit testing, and what they used.

It looks like either no-one bothers, or no-one wants to tell me.  Boo hoo!
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next seven days.

EE Cleanup Volunteer
PAQed, with points refunded (250)

E-E Admin

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.