Thread: what can not be tested in C++ unit testing?

  1. #1
    Registered User
    Join Date
    Mar 2008
    Location
    New York
    Posts
    24

    what can not be tested in C++ unit testing?

    Hi,

    Hi I am sorry if its not the right place to put the question.(I'll request modeartor to put it to right place, but i think we dont have a subforum to testing c++ program).

    Coming to my question, what kind of functions can be tested by unit testing. If a function,
    take some arguments and returns a value. its easy to write test code for it. But what if a functions takes no argument and call few other functions inside it (and those functions are from different classes). How to write test code for it. Will it still be called a unit test.

    I have read many articles over net but getting no clear idea. I am currently using QT test framework ( qttestlib) but i m interested in c++ unit testing in general(CppUnit or any other).

    A good reference to book or article will also be a great help.

    Warm regards,
    Alex

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    There's not much that flat out cant be unit tested. There's a lot of stuff that is rather hard to unit test, and some stuff that's downright insanely difficult, but yet still possible to unit test. Generally for unit testing you don't go for 100% coverage. You go for the low-hanging fruit, and maybe a few of those half way up as well.
    You might mock up your UI and test the model and/or controller part of your MVC implementation, whilst not actually testing the real UI itself, for instance.

    Where it does work very well (where you can expect to get 100% coverage) is in utilitiy libraries where everything is just inputs and outputs. E.g. a bignum library.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help me please.
    By yann in forum C Programming
    Replies: 15
    Last Post: 09-29-2009, 09:04 PM
  2. Replies: 3
    Last Post: 05-11-2009, 04:50 AM
  3. A Question About Unit Testing
    By Tonto in forum C++ Programming
    Replies: 2
    Last Post: 12-14-2006, 08:22 PM
  4. newbie here.. pls help me in this program!
    By rothj0hn in forum C Programming
    Replies: 2
    Last Post: 02-01-2006, 10:40 PM
  5. Unit testing tools for .NET ?
    By gicio in forum C# Programming
    Replies: 0
    Last Post: 11-10-2003, 04:43 AM