Hi,

ok I need to write this somewhere down, since it appears to be a very
common question.

Here my advice and it is irrelevant what framework you use. You do not
really want to have your unit test code in your production code, so the
simple solution is as follows:

Create a static library and add all source files to that, except the
"main.cpp". Your executable only contains the "main.cpp" (the file that
holds your main function) and link to the library. Although the build
process is slightly more complicated, the end result is the same, one
executable. Next you create a second executable, put all your unit tests in
there and link that to your library. This is your unit test executable. For
extra points make the unit test executable being run on every build
("custom build step").

Sean

On Wed, Feb 22, 2012 at 8:54 PM, Teto <matta...@gmail.com> wrote:

> Hi,
>
> I am new to program testing. I am creating a game and I want to add
> tests to check that when I load a gameState, its member function
> isLoaded() returns true for instance.
> I understand it's very practical to use unittest-cpp to test
> libraries. You just need to link them but when you are dealing with a
> program what's the advised way ? Should I add the tests directly into
> my main project and disable them with some kind of macros ? or just
> add my game source files to my tests project (codeblocks).
> Is the use of another framework than unittest++ advised ?
>
> I know it's more tdd related than unittest related but I couldn't find
> a better place and I got unittestcpp running in 5 minutes so I would
> like to stick with it.
>
> Matt
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> unittest-cpp-devel mailing list
> unittest-cpp-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/unittest-cpp-devel
>
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
unittest-cpp-devel mailing list
unittest-cpp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unittest-cpp-devel

Reply via email to