Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Inheriting Tests and Other Test Design Issues

by Steve_p (Priest)
on Sep 27, 2003 at 15:09 UTC ( #294649=note: print w/replies, xml ) Need Help??


in reply to Inheriting Tests and Other Test Design Issues

I'm not sure that inheritance is the correct thing. In fact, I'm not really sure why you would use inheritance. You're tests should be testing behaviors. So, if two classes have the same behaviors, they should be tested together. For example, if I have a class A and subclass B and they both have a method foo and a->foo() will be equal to b->foo() in all cases, then they should be tested together in the same place.

So, what I would do is something somewhat different from what you have above. For class A and subclass B, I would write:

  • A set of test cases for the common functionality of A and B.
  • A set of test cases for all the unique functionality in A. This might include constructors or methods overridden by B.
  • A set or class of test cases for all the unique functionality in B. This would include all the new functionality in B.

Then, down the road, if I create a new subclass of A, I may have to refactor my test cases to cover all my bases, but it will keep me from repeating code.

  • Comment on Re: Inheriting Tests and Other Test Design Issues

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://294649]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2020-03-31 06:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (180 votes). Check out past polls.

    Notices?