User forums > Announcements

Unit testing in Code::Blocks

<< < (3/4) > >>

dirluca:

--- Quote from: killerbot on September 09, 2009, 01:36:38 pm ---Dear All,

As a long lived promise I finally finished my first article on unit testing and Code::Blocks.

It can be found at : http://wiki.codeblocks.org/index.php?title=UnitTesting

There's much more to come, but for the moment it already provides a first introduction. It even contains a Test Driven Development example, extremely simple but the easier to grasp.
I am sure the text currently contains a lot of typos, just PM them to me, and I will fix them.

FYI : the unit test framework used is UnitTest++ : http://unittest-cpp.sourceforge.net/


Cheers.

--- End quote ---

Hi everybody,
I am pretty new to Code::Blocks (and to c++ as a whole) but I like it very much. I was expecially happy when I found out it was starting to embed the UnitTest++ facilities.

But I ran into some problems following the tutorial. Precisely I couldn't build the libUnitTest++ project. I got a

--- Code: ---||=== UnitTest++, Debug ===|
||warning: command line option "-Wmissing-declarations" is valid for C/ObjC but not for C++|
||warning: command line option "-Wmain" is valid for C/ObjC but not for C++|
||=== Build finished: 0 errors, 2 warnings ===|

--- End code ---
message (the same happens with the Release target). Running code::blocks 8.02 on windows 7 64bit.

Any help would be greatly appreciated. Please forgive me if it is a newbie silly question!

Luca

killerbot:
Yes, the compiler you are using (probably the one that came with CB 8.02) is too old, and can't cope with those compiler options.

I would suggest the following :
* uninstall CB 8.02
* get a nightly build from the forum : http://forums.codeblocks.org/index.php/board,20.0.html
* and get a more recent MinGW GCC (TDM's builds are very nice : http://www.tdragon.net/recentgcc/ )

An alternative is, keep using what you have, and remove those options from the UnitTest project.
But then you will miss out on all the new stuff of CB, and GCC ;-)

eckard_klotz:
Hello All.

Since a while I started to use UnitTest++ like described by killerbot in his tutorial. And the basics a working very well, especial that it is possible to jump directly into the code out of the build-log.

But for some reasons I have the need to get some more information somewhere. For example if I test a function with parameters it will be good to now them if there is a fail. The only possibility I know now is to have one single test-function for every set of test-parameters. But if I use a test-loop to iterate over an array of test-parameters, since the test-algorithm is always the same, I see currently no possibility to know which set of test-parameters result into the fails.

For example let’s think about testing the LeapYear function in a loop where the given year will be changed from 1700 to 2700 we just have to provide a result-data array for the check in a small loop and all test can be done. But once we have a fail we have no information which test-value and which result-value where the problem.

Is there a possibility to provide UnitTest++ some additional information that will be defined while one test-cycle and that will be displayed together with the fail-statement in the build-log?

Best regards,
                       Eckard Klotz

killerbot:
I am not sure, but sometimes the test macros exist, with and optional message, and you can format/construct that message as you like.
But I am not sure if that is possible (I use different unit test frameworks from time to time, so I end up mixing information).

So in the example of the leapyear, you could have printed in the message the year you are testing.

defyax:
I really want to Unit text in code Blocks.
When I found this articles, very gratitude for your work.
But I can't get your project file in sourceforge.
How can I download your project?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version