1

How effective is the CXX test framework, given that you are writing unit test cases around the code that you have written. Any bug in the code might as well get translated into a bug in the unit test code as well? Isn't it something like two negatives make a positive?

Also, the time and effort spent on CXX is at least equal to if not more than the coding effort.

Need your thoughts on this since I'm not in favor of this framework being used in my project and am looking for strong points to oppose it.

On the other hand, if you think it's beneficial, please do enlighten me :).

Pete
  • 10,310
  • 7
  • 53
  • 59
Shree
  • 4,627
  • 6
  • 37
  • 49

4 Answers4

4

Google offers a fantastic C++ testing framework that I have used... I never used any other C++ testing framework, and had limited experience with Junit, and I was able to pick this up very quickly, as the documentation is good. It's important to use a good testing framework, because testing is too important to give up on because of frustration with the framework. Here is a link:

http://code.google.com/p/googletest/

Hope this helps!

Tom
  • 21,468
  • 6
  • 39
  • 44
2

CXX is not very active, and writing unit test generally involves a lot of efforts. But when the first refactoring comes in, you're very grateful of the spent effort.

I've used Boost.Test & CPPUNIT. I would prefer a little bit Boost.Test, but yes, you have to write your own projects, files etc.

If you know a tool to generate your skeleton from your code, I'm all ears. :)

I would suggest that you give a try to Boost.Test and CPPUNIT. If you think there are better it will give you good rounds to oppose CXXUNIT as you will propose alternatives.

Edouard A.
  • 6,100
  • 26
  • 31
  • CxxTest does not need to be active. Unlike CppUnit, it is complete and simple to use. It's only awkwardness comes from the no <*stream> dependency policy. – Luc Hermitte Apr 06 '09 at 12:39
  • 1
    I'm sorry to disagree, but it's important to use maintained software. What happens when it becomes incompatible with your compiler? When there is a bug? You do it yourself? – Edouard A. Apr 06 '09 at 14:13
  • 4
    In other cases I may have agreed. CxxTest doesn't use advanced C++ templates, nor require RTTI, nor require exceptions, nor most of the standard library in order to be compatible with most older compilers, and future ones. And if I must patch the tool, I'll will, it is very simple framework. – Luc Hermitte Apr 06 '09 at 19:02
  • 1
    In a professional context it's very problematic to know you're working on an unsupported product. I know I wouldn't allow that in my company. Having the source code doesn't mean being able to support it. – Edouard A. Apr 07 '09 at 09:00
2

I am using cxxtest. Regressive testing is an expensive task that we only use to validate our software libraries - which provide a platform independent layer for our apps. This is to ensure that all changes will not affect the stability of the code since so many apps and projects and dependent on them.

We couple cxxtest with coverage analysis to ensure that test coverage is sufficient and also with CruiseControl to automate it.

But we do not do this for apps. Too much effort.

Building a test app is just as difficult as writing the whole library itself. I agree that you will need to work out whether it is worth your while.

I think Joel has something to say about this too: http://www.joelonsoftware.com/items/2009/01/31.html

sep
  • 3,409
  • 4
  • 29
  • 32
  • "We couple cxxtest with coverage analysis to ensure that test coverage is sufficient and also with CruiseControl to automate it." How did you do this? What is the coverage tool? – Fausto Carvalho Marques Silva May 11 '11 at 14:02
  • We use VectorCAST. It allows instrumentation of source code before it is passed to the compiler. – sep May 23 '11 at 11:54
0

I prefer header-only test frameworks, here are two of them: TUT and Catch . I used TUT before in several projects, and found Catch not long ago.

1) TUT -- C++ Template Unit Test Framework

TUT is a small and portable unit test framework for C++.

  • TUT is very portable, no matter what compiler or OS you use.
  • TUT consists of header files only. No libraries required, deployment has never been easier.
  • Custom reporter interface allows to integrate TUT with virtually any IDE or tool in the world.
  • Support for multi-process testing (testing deadlocks and timeouts is under way).
  • TUT is free and distributed under a BSD-like license.
  • Tests are organised into named test groups.
  • Regression (all tests in the application), one-group or one-test execution.
  • Pure C++, no macros!

2) Catch -- A modern, C++-native, header-only, framework for unit-tests, TDD and BDD

What's the Catch?

Catch stands for C++ Automated Test Cases in Headers and is a multi-paradigm automated test framework for C++ and Objective-C (and, maybe, C). It is implemented entirely in a set of header files, but is packaged up as a single header for extra convenience.

douyw
  • 4,034
  • 1
  • 30
  • 28