Topic: How to test the C++ program?


Author: magnus@thakhasis.solace.mh.se (Magnus Nasholm)
Date: 16 Nov 1994 17:31:01 +0100
Raw View
Your question is a bit wide, but this is what I do:
For every class (or subclass, if it's an abstract one) I write a main-loop
at the end surrounded by #ifdef MAIN and #endif.
Then, as I have all my classes in separate files, I simply compile with
(usually) -DMAIN.
Of course, in main() you shall try everything that the class is able to do.
That is one of the main purposes with C++. When the class is tested and ok,
you never have to worry about it again...

/Magnus Nasholm




Author: hdsimms@teleport.com (Howard Simms)
Date: Wed, 16 Nov 1994 21:26:18 UNDEFINED
Raw View
In article <magnus.785003153@thakhasis> magnus@thakhasis.solace.mh.se (Magnus Nasholm) writes:
>Your question is a bit wide, but this is what I do:
>For every class (or subclass, if it's an abstract one) I write a main-loop
>at the end surrounded by #ifdef MAIN and #endif.
>Then, as I have all my classes in separate files, I simply compile with
>(usually) -DMAIN.
>Of course, in main() you shall try everything that the class is able to do.
>That is one of the main purposes with C++. When the class is tested and ok,
>you never have to worry about it again...

I'm sorry I missed the lead-in on this thread.  In the testing I've done,
I conditionally include a friend declaration, like the following:

   class X
   {
   #ifdef TEST
      friend class XTest;
   #endif
      // other class contents
   };

and keep my test code in a separate file.  I'm always open for new
alternatives, though.

Howard Simms

P.S. Shouldn't we be posting these messages to another newsgroup??





Author: david@csie.nctu.edu.tw (david)
Date: 17 Nov 1994 08:40:00 GMT
Raw View
Howard Simms (hdsimms@teleport.com) wrote:
: In article <magnus.785003153@thakhasis> magnus@thakhasis.solace.mh.se (Magnus Nasholm) writes:
: >Your question is a bit wide, but this is what I do:
: >For every class (or subclass, if it's an abstract one) I write a main-loop
: >at the end surrounded by #ifdef MAIN and #endif.
: >Then, as I have all my classes in separate files, I simply compile with
: >(usually) -DMAIN.
: >Of course, in main() you shall try everything that the class is able to do.
: >That is one of the main purposes with C++. When the class is tested and ok,
: >you never have to worry about it again...

: I'm sorry I missed the lead-in on this thread.  In the testing I've done,
: I conditionally include a friend declaration, like the following:

:    class X
:    {
:    #ifdef TEST
:       friend class XTest;
:    #endif
:       // other class contents
:    };

: and keep my test code in a separate file.  I'm always open for new
: alternatives, though.

: Howard Simms

: P.S. Shouldn't we be posting these messages to another newsgroup??


     thanks!!

     But I still have many questions.

     1. How do you decide the test order of classes?

     2. Do you want to write a class test driver? How to write?

     3. How do you decide the test order of methods in a class?

     4. When you test all methods, you must test the integrated condition.
        How do you test the integration testing in the intra-class or in the
        inter-class ?

     5. ...... I forget now.

      Can you answer my questions ? Thanks!!

                                                     David Ko








Author: Alan@doughnut.demon.co.uk (Alan Bellingham)
Date: Thu, 17 Nov 1994 13:43:57 +0000
Raw View
In article: <3a78gv$cjs@news.csie.nctu.edu.tw>  david@csie.nctu.edu.tw (david) writes:
>
>                 as title.
>
>                                                    David Ko
OK, you've got us puzzled. _Which_ C++ program?

Alan Bellingham
--
Alan@doughnut.demon.co.uk    "... not many creatures are twenty feet across,
Alan@episys.win-uk.net       one inch thick and deep fried." Terry Pratchett
ACCU: Association of C & C++ Users                    First ever Elite pilot





Author: david@csie.nctu.edu.tw (david)
Date: 18 Nov 1994 02:19:13 GMT
Raw View
Alan Bellingham (Alan@doughnut.demon.co.uk) wrote:
: In article: <3a78gv$cjs@news.csie.nctu.edu.tw>  david@csie.nctu.edu.tw (david) writes:
: >
: >                 as title.
: >
: >                                                    David Ko
: OK, you've got us puzzled. _Which_ C++ program?

: Alan Bellingham
: --
: Alan@doughnut.demon.co.uk    "... not many creatures are twenty feet across,
: Alan@episys.win-uk.net       one inch thick and deep fried." Terry Pratchett
: ACCU: Association of C & C++ Users                    First ever Elite pilot

   sorry , how to test any c++ program?

                                             david ko






Author: hdsimms@teleport.com (Howard Simms)
Date: Thu, 17 Nov 1994 23:20:36 UNDEFINED
Raw View
In article <3af4t0$b0s@news.csie.nctu.edu.tw> david@csie.nctu.edu.tw (david) writes:
>     But I still have many questions.
>
>     1. How do you decide the test order of classes?

I don't have any "recipe"-type answers regarding software testing.  Some
software testing lies in using good judgment to find a starting place.
For example, "standalone" classes are good starting points.  If a base
class is instantiable, that also is a good starting place.  Start from
the most simple, and build to the more complex.

>     2. Do you want to write a class test driver? How to write?
>     3. How do you decide the test order of methods in a class?

Again, this is up to you.  More often than not, private methods are called
in the implementation of interface functions.  These private methods could
be a good starting point.

>     4. When you test all methods, you must test the integrated condition.
>        How do you test the integration testing in the intra-class or in the
>        inter-class ?

Are you asking how to do integration testing?  I'm not sure what
"testing the integrated condition" means.  Could you elaborate?

>        Can you answer my questions ? Thanks!!

I'm not a software testing expert.  I think that you should grab a book on
software testing.  I've learned some basic tips from "Software Testing
Techniques" by Boris Beizer.  Good Luck!

Howard Simms









Author: david@csie.nctu.edu.tw (david)
Date: 14 Nov 1994 08:52:47 GMT
Raw View
                as title.

                                                   David Ko