September 10, 2006 OOP, Unit Testing

Benefits of Testability

I have been having a hard sell of “testability is a good thing” at my work. I feel that unit testing leads to testability leads to good OO. The dynamic mocking application TypeMock.NET has not helped: nor has the article Stop Designing for Testability. TypeMock is a powerful application but I think that it can be misused to allow poor design with ease of unit testing. The pain that unit testing creates when dealing with a low testability test subject is experienced close to when the test subject was created. This gives the developer rapid feedback that there is a design issue. The feedback is experience while the developer is still in flow and can make the needed changes with the lest impact to schedule. So unit testing and testability are like an alarm indicating early that there is a design problem. This sounds like a good thing to me, something that I would not want to circumvent or avoid. There are a lot of other characteristics of design that are related to testability. In particular the list below are benefits to testability.

  • Understandability
  • Modifiability
  • Availability
  • Flexibility
  • Maintainability
  • Reliability
  • Usability
  • Changeability
  • Fault Tolerance

This list was gathered from Appendix D of Stefan Jungmayr’s thesis Improving testability of object-oriented systems.

If some or all of the list is important to your project then testability will help you get it.

20,700 Total Views

20 to “Benefits of Testability”

Trackbacks/Pingbacks

  1. codedancer says:

    Tools instead of testability…

  2. 14 facets of TypeMock.NET and Designing for Testability…

    There has been much talk about Designing for Testability lately.Basically the argument is: Should our Tests (Enabling Mock Insersions) Drive our design? or should we use tools to do it for us?Here is what 14 of are our community have to say a…

  3. [...] There was a pit stop at YAGNI and Testability as it had some bearing on the OCP. It was all kicked of by Benefits of Testability. Which was inspired by Dr. Stefan Jungmayr’s dissertation Improving testability of object oriented system. [...]

  4. [...] All the benefits that come with testability. [...]

  5. [...] Before you read what I wrote, you can read posts that say "don’t use Typemock" here, here,here and there are others. Most fear that Typemock will make it easy for you to write non testable code, or that your design will suffer for it. You can read my thoughts on this here and here. [...]

  1. Lenny says...

    There’s a strong argument for “don’t design for testability”. I don’t read that as “make bad designs”, but rather don’t let the testing framework dictate your design. Let the business needs dictate design and use a testing framework that allows adequate testing of your design.

    It seems to me it really boils down to a question of purity. If you’re on OO purist, then relying on “traditional” unit testing frameworks to drive your design (or that of your less capable peers) will be seen as a good thing. If, however, you are more concerned with business functionality and a solid design that meets the business needs, then TypeMock seems to fit the bill.

    Understanding a highly OO design can be just as daunting as groking spaghetti code. I’m not advocating the latter, just noting that complex OO designs that exist merely to support nUnit testing doesn’t necessarily translate to understandability or maintainability.

    Fault tolerance, reliability and changeability and the other features you list are provided by good unit tests – regardless of methodology. If the tests are valid and good, these features are protected by either nUnit or TypeMock. (While we’re on this point, bad tests can be written in any framework, so I think we’re both operating on the assumption “good” test are being written in either framework.)

    Another area of concern is legacy code. It would be very nice to be able to refactor all your old code to modern standards of OO purity, but that’s just not realistic (some might even say “that’s just crazy talk”). Budget or time constraints almost guarantee legacy code cannot be refactored adequately for a given project. Should the effort be made? Sure, but if something like TypeMock can help ensure existing functionality is protected while adding new features, why not take advantage of it?

    The point of software is to solve a problem. If said problem can be solved reliably and expediently with classes “firmly coupled”, why not allow TypeMock to help confirm proper functionality? Sure, it’s not “coding to interfaces” and not a truly OO design, but it solves the need. OO designs are a bit like normalizing a database. Just as a database can be “over normalized”, software designs can be “over OO’d”.

  2. jflowers says...

    Thanks for thoughtful response Lenny. :-)
    I don’t see how an xUnit framework acts as a force on the design of a product. I do see how trying to get control over a test subject and be able to observe a test subject can act as a force on design.
    The list of benefits including understandability and maintainability are not one man’s opinions. They were identified through empirical evidence.
    Your argument about complex OO as a reason to use TypeMock worries me. I would rather simplify the design and still not use TypeMock. I have never run into a situation were an overly complex design could not be simplified and improve testability.
    TypeMock is a wonderfully powerful tool. It is great for working with legacy code. I imagine that it is particularly good at reducing the desire and pressure to improve a bad design.
    Dynamic mocking reduces the readability of a unit test. I prefer static test doubles. In fact I prefer test stub recorders as the don’t decrease the readability.
    Please let me be clear I think that testability in a system when balanced with the other design principles creates the simplest design expressing all the qualities listed in this blog post. Testability is not about going to extremes just to make something testable.

  3. codedancer says...

    Tools instead of testability…

  4. Creative Coding by Eli Lopian says...

    14 facets of TypeMock.NET and Designing for Testability…

    There has been much talk about Designing for Testability lately.Basically the argument is: Should our Tests (Enabling Mock Insersions) Drive our design? or should we use tools to do it for us?Here is what 14 of are our community have to say a…

  5. JayFlowers > OOD Class Principles and Testability says...

    [...] There was a pit stop at YAGNI and Testability as it had some bearing on the OCP. It was all kicked of by Benefits of Testability. Which was inspired by Dr. Stefan Jungmayr’s dissertation Improving testability of object oriented system. [...]

  6. JayFlowers > A Tune-Up for TDD? says...

    [...] All the benefits that come with testability. [...]

  7. The Case For Typemock | Developer Home says...

    [...] Before you read what I wrote, you can read posts that say "don’t use Typemock" here, here,here and there are others. Most fear that Typemock will make it easy for you to write non testable code, or that your design will suffer for it. You can read my thoughts on this here and here. [...]

  8. s3-us-west-1.amazonaws.com says...

    In addition I also want to say James Bauer is offering 60 days money back assure just to test the strategy talked about in this
    system.

  9. k� lommeknive says...

    Нello to aⅼl, it’s actually a goid fоr mee to go to see this web site,
    it includes valuable Infߋrmation.

  10. wordpress says...

    I blog quite often and I seriously appreciate your content.
    The article has truly pewked my interest.
    I will book mark your website and keep checking for new details about once a week.

    I opted in for your RSS feed as well.

  11. Gordon says...

    Very gopod write-up. I certainly appreciate this website. Keep writing!

  12. wordpress says...

    Hello, i think that i saw you visited my webb site thus i came to “return the favor”.I am attempting to find
    things to enhance my site!I suppose its ok to use a few of your ideas!!

  13. wordpress says...

    Thanks for sharing such a pleasant opinion, article is good, thats
    why i have read it fully

  14. wordpress says...

    Thank you for the good writeup. It if truth be told used to be a enjoyment account it.
    Look complicated to far brought agreeable from you!
    By the way, how can we be in contact?

  15. G6 Tactical Smartwatch says...

    Excellent goods from you, man. I’ve have in mind your stuff previous to and you are just extremely wonderful.
    I actually like what you have obtained here,
    really like what yoou are stating and the way during
    which you assert it. You’re making it enjoyable
    and you still care for to stay it wise. I can not wait to
    read ffar more from you. This iis actually a terrific web site.

  16. Hafzo says...

    Excellent post. I was checking constantly this blog and
    I’m impressed! Extremely useful information specifically the last partt :
    ) I care for such information much. I was looking for this particular information for a long time.
    Thank you and good luck.

  17. Tactical smartwatch says...

    Everyone loves what you guhs tend to be up too.
    Such clever work and reporting! Keep up the fantastic works guys I’veincorporated you gugs to my blogroll.

  18. https://smartwatch-tactical.com/ says...

    WOW just what I was looking for. Came here by searching foor Tactial Smartwatch

  19. wordpress says...

    Have you ever considered writing an e-book or guest authoring
    on other blogs? I have a blog centered on the same information you discuss and would reallky like to have yoou share
    some stories/information. I know my readers would appreciate your work.
    If you’re even remoteoy interested, feel free to send
    me an email.

  20. Ephraim Sunglasses says...

    Remarkabgle issues here. I’m very happy to peer yur post. Thanks
    so much and I’m lookin forward to contact you.
    Will you kindly drop me a e-mail?

Leave a comment

*

here