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

Re: [XP] Re: Mocks: How to make sure they behave like the real thing

Expand Messages
  • D. AndrĂ© Dhondt
    ... the real thing with certain arguments, and asking it to record the real results so it can play them back later...But doesn t it kind of defeat the purpose
    Message 1 of 115 , May 31 9:39 AM
      >You can then tell the Mock what you expect from it by telling it to invoke
      the real thing with certain arguments, and asking it to record the real
      results so it can play them back later...But doesn't it kind of defeat the
      purpose of a Mock?

      That's not quite how it works--the mock instance essentially overrides the
      behavior of the wrapped class and returns the result you proscribed in the
      test setup logic. The record/play metaphor is a bit different than you
      describe--the test fakes out the results--you're not waiting (or recording)
      real results. If you forget to override some method call, the mock could be
      slow--but other than that, mocks are fast.


      --
      D. André Dhondt

      If you're a software developer in the area, join Agile Philly (
      http://groups.yahoo.com/group/agilephilly/)!


      [Non-text portions of this message have been removed]
    • J. B. Rainsberger
      ... I worked on one project trying to organize C code in an OO fashion using various pointer-related idioms I didn t entirely understand. This experience
      Message 115 of 115 , Jun 14, 2007
        George Dinwiddie wrote:

        > J. B. Rainsberger wrote:
        > > I would never use mocks on a C project; but of course, I would never
        > > work on a C project.
        >
        > I've certainly used fakes and stubs on C projects. In fact, the
        > practice lead me to heavy reliance on function pointers long before I
        > started using OO.

        I worked on one project trying to organize C code in an OO fashion using
        various pointer-related idioms I didn't entirely understand. This
        experience rather entrenched my distrust of C.
        --
        J. B. (Joe) Rainsberger :: http://www.jbrains.ca
        Your guide to software craftsmanship
        JUnit Recipes: Practical Methods for Programmer Testing
        2005 Gordon Pask Award for contribution Agile Software Practice
      Your message has been successfully submitted and would be delivered to recipients shortly.