|
-
April 3rd, 2007, 12:07 AM
#1
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.
-
April 3rd, 2007, 01:56 PM
#2
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
-
April 4th, 2007, 12:08 AM
#3
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
-
April 4th, 2007, 03:14 AM
#4
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).
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
April 4th, 2007, 07:49 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|