Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Inheriting Tests and Other Test Design Issues

by Steve_p (Priest)
on Sep 27, 2003 at 15:09 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://294649]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-04-20 03:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found