Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit testing an executable project

Maybe I am not thinking about this correctly. I am starting my second project using unit tests. My first project I rolled my own, for this project I am trying out Boost::test.

My question is, what are the proper procedures for unit testing projects that compile into executables? It seems like everything I see out there is for libraries and dependencies. I want my exe project to be unit tested, but I do not want a bunch of unit test functions floating around in the binary, nor do I want to do

#ifdef _DEBUG
    BOOST_AUTO_TEST_CASE( my_func )
    {
    }
#endif

around all my tests.

I thought about creating a separate project for unit tests, but that does not really work for executable.. unless I want to do some fancy pre-build operation copying from my other project into the test project..

Any thoughts or ideas?

like image 771
Charles Avatar asked Dec 15 '09 03:12

Charles


People also ask

How are unit tests executed?

Unit tests can be performed manually or automated. Those employing a manual method may have an instinctual document made detailing each step in the process; however, automated testing is the more common method to unit tests. Automated approaches commonly use a testing framework to develop test cases.


1 Answers

The project can be compiled as a library and this library linked, possibly statically, in two separate executables: the "project", which will be delivered, and the unit tests.

Now the problem seems to originate from your IDE, which one is it ? Does it allow to create two binaries for one project ?

like image 194
philant Avatar answered Sep 29 '22 14:09

philant