CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2005
    Posts
    8

    Question Testing strategies

    Hi,

    I'm doing Unit testing for C++ software. If i could have any testing strategies for the different OOPS concepts like checking for inheritance, polymorphism then it would be very helpful. Any suggestions where I could find them?

    Regards,
    Carol.

  2. #2
    Join Date
    Mar 2002
    Location
    California
    Posts
    1,582

    Re: Testing strategies

    Unit tests should not care about inheritance or polymorphism, but about testing interfaces, pre and post conditions, functionality, etc.

    "Unit testing" is over used and can mean different things. What are you trying to accomplish.

    Jeff

  3. #3
    Join Date
    Oct 2005
    Posts
    8

    Unhappy Re: Testing strategies

    Hi Jeff,

    Here im in a situation to test interfaces as seperate classes. I shld also test the polymorphism behaviour of functions too. So it would be of help if i get to know certain basic testing strategies like if i'm going to test an inherited class then these are the points that i shld be more concerned abt...sort of...
    Could u help me find some?

    Regards,
    Carol

  4. #4
    Join Date
    Feb 2005
    Location
    "The Capital"
    Posts
    5,306

    Re: Testing strategies

    Do you have use cases/test cases? How did you start with coding? Make different objects as part of the test spec and invoke the functionalities you want - see what you wish to observe and compare with what actually happens. I don't think it is more difficult than that. However, why would one want to check the implementation details (in a more general sense of an application) - like inheritance and polymorphism? What you should be doing is testing the stuff that the users of the class would be using. If you are writing a library then that's a different matter. You have a class and a set of public interfaces - you invoke them as they should and take observations.

    Boost have a test framework - http://www.boost.org/libs/test/doc/index.html. I haven't used it. There may be more freely and commercially available. You might want to take a look at the unit tests done by the people at boost. Here is one that I can find for you: http://www.boost.org/libs/smart_ptr/test/ or http://www.boost.org/libs/serialization/test/

    There are more there to look at - the directory structure is the same as above - where you replace the library name with the one you want to look at (note : smart_ptr for smart pointer library, serialization for serialization library in the url path).

  5. #5
    Join Date
    Jan 2006
    Location
    Belo Horizonte, Brazil
    Posts
    405

    Re: Testing strategies

    Hi.

    Unit testing is testing classes as a unit (naturally ). It's pretty much what exterminator said. You set up your enviroment and data, execute the methods you want, and verify/check the results. If you have inheritance, this is no problem. Just run the tests for each class/method that participates in the hierarchy.

    In fact, some problems might arise when testing some specific things. For example, what are the best strategies for testing protected/private member functions, factories, data access classes, etc? Fortunately, there're good approaches for most of these situations.

    I've been using the CppUnit framework for a while. You can also find a tutorial about unit testing in their website: http://cppunit.sourceforge.net/cppunit-wiki

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured