Loading ...
Sorry, an error occurred while loading the content.
 

[XP] Re: Re: [XP] Testing interfaces and abstract classes

Expand Messages
  • Robert C. Martin
    ... Yes. You will find that interfaces are meant for use by clients. So when you test the clients, you will have to implement the interfaces that they use
    Message 1 of 1 , Mar 14, 2000
      > -----Original Message-----
      > From: walter.van.iterson@...
      > [mailto:walter.van.iterson@...]
      > Sent: Thursday, March 09, 2000 8:41 AM
      > To: extremeprogramming@...
      > Subject: [XP] Testing interfaces and abstract classes
      >
      >
      > Hi all,
      >
      > In XP, all classes that are released must have unit test classes.
      > Great idea! Changes the focus from developer-perspective to
      > user-perspective, gives immediate feedback if your code breaks
      > anything. We should have thought of it ages ago!
      >
      > But...
      > Interfaces have no implementation to test.
      >
      > Abstract classes can't be instantiated. Instantiating subclasses
      > may test overridden methods instead of the implemented part of the
      > abstract class.
      >
      > Does anybody know how to test these?

      Yes. You will find that interfaces are meant for use by clients. So
      when you test the clients, you will have to implement the interfaces
      that they use with test stub classes. The same is true of abstract
      classes. They will be used by clients, and the tests of the clients
      will have to stub those abstractions.

      If you have implemented functions in an abstract class, you can test
      them by stubbing up the abstract methods in your unit tests.


      Robert C. Martin | President | Training Courses:
      Object Mentor Inc. | rmartin@... | OOD, Patterns, C++,
      Java,
      PO Box 85 | Tel: (800) 338-6716 | Extreme Programming.
      Grayslake IL 60030 | Fax: (847) 548-6853 |
      http://www.objectmentor.com

      "One of the great commandments of science is:
      'Mistrust arguments from authority.'" -- Carl Sagan
    Your message has been successfully submitted and would be delivered to recipients shortly.