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

Re: [XP] Re: Stubs, Fakes, and Mocks

Expand Messages
  • Steve Freeman
    ... Yes, but you don t implement an entire level at a time, but a series of end-to-end slices. ... Personally, I ve stopped trying to write bottom-up layers in
    Message 1 of 22 , Jan 1, 2008
      On 31 Dec 2007, at 19:19, Vlad wrote:
      > My understanding of "mock-driven" development is that one
      > tends to start development at the highest level possible to
      > "discover" the entry-point interface, and then one delves
      > into the logic of the application one level at a time,
      > mocking out the level immediately below.
      >
      Yes, but you don't implement an entire level at a time, but a series
      of end-to-end slices.

      > I don't know if I've had the experience of discovering that
      > my lower-level building blocks were completely wrong
      > as I started to reach the higher-level code. I do refactor
      > as I go along so that probably mitigates this kind of
      > potential pitfall at least to some extent.
      >
      Personally, I've stopped trying to write bottom-up layers in
      isolation because I got tired of building stuff I didn't want. It's
      not so much code that's completely wrong as all the little dead-ends
      and unused pieces.

      S.

      Steve Freeman
      http://www.mockobjects.com

      Winner of the Agile Alliance Gordon Pask award 2006
    • Steve Freeman
      ... Of course, it s a matter of degree and mind-set. People build working systems bottom-up all the time. My experience is that I usually spend too much time
      Message 2 of 22 , Jan 1, 2008
        On 31 Dec 2007, at 03:16, Steve Howell wrote:
        > The discussion on the blog so far on the page deals
        > with bottom-up vs. top-down. I don't exactly
        > understand the poster Steven's point that building
        > bottom-up leads to creating the wrong objects. That
        > doesn't resonate with any experiences that I've had so
        > far.
        >

        Of course, it's a matter of degree and mind-set. People build working
        systems bottom-up all the time. My experience is that I usually spend
        too much time writing speculative code that turns out not to be quite
        right or used. Of course, if you're developing incrementally then
        it's hard to stray too far from the path.

        A more interesting difference is I find that top-down helps me think
        about a service in terms of its clients, what they need from the
        world, rather than its provider, what it might usefully do. I find
        the result tends to be more expressive of whichever domain I'm in at
        the time.

        S.

        Steve Freeman
        http://www.mockobjects.com

        Winner of the Agile Alliance Gordon Pask award 2006
      • Steve Howell
        ... Ok, makes sense. In this case, do you tend to use the mocks as scaffolding to be thrown away later, or do you keep the mocks around even after you ve
        Message 3 of 22 , Jan 1, 2008
          --- Steve Freeman <smgfreeman@...> wrote:

          > On 31 Dec 2007, at 03:16, Steve Howell wrote:
          > > The discussion on the blog so far on the page
          > deals
          > > with bottom-up vs. top-down. I don't exactly
          > > understand the poster Steven's point that building
          > > bottom-up leads to creating the wrong objects.
          > That
          > > doesn't resonate with any experiences that I've
          > had so
          > > far.
          > >
          >
          > Of course, it's a matter of degree and mind-set.
          > People build working
          > systems bottom-up all the time. My experience is
          > that I usually spend
          > too much time writing speculative code that turns
          > out not to be quite
          > right or used. Of course, if you're developing
          > incrementally then
          > it's hard to stray too far from the path.
          >
          > A more interesting difference is I find that
          > top-down helps me think
          > about a service in terms of its clients, what they
          > need from the
          > world, rather than its provider, what it might
          > usefully do. I find
          > the result tends to be more expressive of whichever
          > domain I'm in at
          > the time.
          >

          Ok, makes sense. In this case, do you tend to use the
          mocks as scaffolding to be thrown away later, or do
          you keep the mocks around even after you've gotten
          around to implementing the "provider" layers (assuming
          they're reasonably fast)?




          ____________________________________________________________________________________
          Looking for last minute shopping deals?
          Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
        • J. B. Rainsberger
          ... I find it hard to express what I want to express in a way that doesn t risk Vlad being upset with me, so I throw myself on your mercy and beg you to
          Message 4 of 22 , Jan 1, 2008
            On Dec 30, 2007, at 18:07 , Vlad wrote:
            > This blog entry is my attempt to explain the different kinds test-only
            > objects that can be substituted for the real thing in automated tests:
            > Stubs, Fakes, and Mocks. It can be easy to get confused, so I hope
            > this entry helps!
            >
            > http://vladimirlevin.blogspot.com/2007/11/stubs-fakes-mocks.html
            >
            I find it hard to express what I want to express in a way that doesn't
            risk Vlad being upset with me, so I throw myself on your mercy and beg
            you to interpret me generously.

            Is it a failing of ours as leaders in this arena that so many people
            find it necessary to re-explain this? or is it merely a consequence of
            the vastness of the internet?

            Vlad, please understand me, I haven't read your article, so I'm not
            judging its quality, but I see one of these every month or so, and I
            wonder why so many people find it necessary to go over such well-worn
            ground. I'm not complaining, but rather seeking to understand.
            ----
            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
          • Steve Howell
            ... I would venture neither. The best way to deepen your understanding of an important topic is to publish your own interpretation of multiple sources and
            Message 5 of 22 , Jan 1, 2008
              --- "J. B. Rainsberger" <jbrains762@...> wrote:
              > Is it a failing of ours as leaders in this arena
              > that so many people
              > find it necessary to re-explain this? or is it
              > merely a consequence of
              > the vastness of the internet?
              >

              I would venture neither. The best way to deepen your
              understanding of an important topic is to publish your
              own interpretation of multiple sources and have it
              reviewed. At least that's what my professors told me.

              Vlad referenced Martin Fowler in the blog FWIW:

              http://vladimirlevin.blogspot.com/2007/11/stubs-fakes-mocks.html




              ____________________________________________________________________________________
              Never miss a thing. Make Yahoo your home page.
              http://www.yahoo.com/r/hs
            • Ron Jeffries
              ... Well, not having read it, we risk the possibility that, at last, someone has explained the topic /well/. I write things, first to understand them, then to
              Message 6 of 22 , Jan 2, 2008
                Hello, J.. On Tuesday, January 1, 2008, at 9:51:56 PM, you wrote:

                > Vlad, please understand me, I haven't read your article, so I'm not
                > judging its quality, but I see one of these every month or so, and I
                > wonder why so many people find it necessary to go over such well-worn
                > ground. I'm not complaining, but rather seeking to understand.

                Well, not having read it, we risk the possibility that, at last,
                someone has explained the topic /well/.

                I write things, first to understand them, then to share them. I
                write things differently all the time in hopes that one of the
                writings will help someone else to gain an understanding they didn't
                previously have.

                Is there a definitive and clear write up of this topic which, if
                only all would read it, would enlighten us all and give us all the
                same understanding? Based on what I have read so far about these
                items, I'd like to know what it is, to read it, and to have everyone
                else read it also.

                But my guess is that the ground may be well worn, but that it is not
                all that well understood by all who tread it.

                Ron Jeffries
                www.XProgramming.com
                Fear is the mindkiller. --Bene Gesserit Litany Against Fear
              • Vlad
                My goal was to explain the differences in a way that I hoped would be as intuitive as possible (i.e. informal and minus pompous language) illustrated with
                Message 7 of 22 , Jan 2, 2008
                  My goal was to explain the differences in a way that I hoped would be
                  as intuitive as possible (i.e. informal and minus pompous language)
                  illustrated with several straightforward but practical examples. I
                  have also added the following links to other material on the subject.

                  http://en.wikipedia.org/wiki/Mock_object
                  href="http://www.c2.com/cgi/wiki?MockObject
                  href="http://xunitpatterns.com/Test%20Double.html
                  href="http://martinfowler.com/articles/mocksArentStubs.html
                  href="http://langrsoft.com/articles/mocking.shtml

                  My intent was also to offer my personal sense of when these different
                  kinds of test-only objects (aka test-doubles) should and should not be
                  used. If somebody offers corrections to my blog entry or additional
                  helpful links, I'll happily incorporate them.

                  Based on what I was able to find with some searching online, I was
                  hoping to fill a small but helpful niche in the mock-objects/tdd
                  landscape.

                  --- In extremeprogramming@yahoogroups.com, "J. B. Rainsberger"
                  <jbrains762@...> wrote:
                  > Is it a failing of ours as leaders in this arena that so many people
                  > find it necessary to re-explain this? or is it merely a consequence of
                  > the vastness of the internet?
                • J. B. Rainsberger
                  ... OK. I buy that. Thanks. ... J. B. (Joe) Rainsberger :: http://www.jbrains.ca Your guide to software craftsmanship JUnit Recipes: Practical Methods for
                  Message 8 of 22 , Jan 2, 2008
                    On Jan 1, 2008, at 21:00 , Steve Howell wrote:
                    > --- "J. B. Rainsberger" <jbrains762@...> wrote:
                    > > Is it a failing of ours as leaders in this arena
                    > > that so many people
                    > > find it necessary to re-explain this? or is it
                    > > merely a consequence of
                    > > the vastness of the internet?
                    > >
                    >
                    > I would venture neither. The best way to deepen your
                    > understanding of an important topic is to publish your
                    > own interpretation of multiple sources and have it
                    > reviewed. At least that's what my professors told me.
                    >
                    > Vlad referenced Martin Fowler in the blog FWIW:
                    >
                    > http://vladimirlevin.blogspot.com/2007/11/stubs-fakes-mocks.html
                    >
                    OK. I buy that. Thanks.
                    ----
                    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
                  • J. B. Rainsberger
                    ... For sure, I buy that. Thanks. ... J. B. (Joe) Rainsberger :: http://www.jbrains.ca Your guide to software craftsmanship JUnit Recipes: Practical Methods
                    Message 9 of 22 , Jan 2, 2008
                      On Jan 2, 2008, at 06:46 , Ron Jeffries wrote:
                      > But my guess is that the ground may be well worn, but that it is not
                      > all that well understood by all who tread it.
                      >
                      For sure, I buy that. Thanks.
                      ----
                      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
                    • Steve Freeman
                      ... Well, usually there isn t much to keep since I usually use a framework to do all the work. As a rule I keep the unit tests unless something significant
                      Message 10 of 22 , Jan 2, 2008
                        On 1 Jan 2008, at 22:08, Steve Howell wrote:
                        > Ok, makes sense. In this case, do you tend to use the
                        > mocks as scaffolding to be thrown away later, or do
                        > you keep the mocks around even after you've gotten
                        > around to implementing the "provider" layers (assuming
                        > they're reasonably fast)?

                        Well, usually there isn't much to "keep" since I usually use a
                        framework to do all the work. As a rule I keep the unit tests unless
                        something significant changes.

                        S.

                        Steve Freeman
                        http://www.mockobjects.com

                        Winner of the Agile Alliance Gordon Pask award 2006
                      • J. B. Rainsberger
                        ... Thanks for explaining. Don t mind me; I think it s great that so many people want to write about this, but it looks from a distance like a bunch of people
                        Message 11 of 22 , Jan 2, 2008
                          On Jan 2, 2008, at 12:59 , Vlad wrote:
                          > My goal was to explain the differences in a way that I hoped would be
                          > as intuitive as possible (i.e. informal and minus pompous language)
                          > illustrated with several straightforward but practical examples. I
                          > have also added the following links to other material on the subject.
                          >
                          > http://en.wikipedia.org/wiki/Mock_object
                          > href="http://www.c2.com/cgi/wiki?MockObject
                          > href="http://xunitpatterns.com/Test%20Double.html
                          > href="http://martinfowler.com/articles/mocksArentStubs.html
                          > href="http://langrsoft.com/articles/mocking.shtml
                          >
                          > My intent was also to offer my personal sense of when these different
                          > kinds of test-only objects (aka test-doubles) should and should not be
                          > used. If somebody offers corrections to my blog entry or additional
                          > helpful links, I'll happily incorporate them.
                          >
                          > Based on what I was able to find with some searching online, I was
                          > hoping to fill a small but helpful niche in the mock-objects/tdd
                          > landscape.
                          >
                          Thanks for explaining. Don't mind me; I think it's great that so many
                          people want to write about this, but it looks from a distance like a
                          bunch of people writing the same thing about the same thing, and that
                          usually makes me wonder why.

                          This also prompts me to write "Stubs aren't mocks", which I've been
                          meaning to do for a few months now. :)

                          Take care.
                          ----
                          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
                        • Adam Dymitruk
                          ... You should keep your mocks. If you are using a powerful framework like Rhino Mocks, you can specify that what is important for you in that one test. The
                          Message 12 of 22 , Jan 2, 2008
                            > Ok, makes sense. In this case, do you tend to use the
                            > mocks as scaffolding to be thrown away later, or do
                            > you keep the mocks around even after you've gotten
                            > around to implementing the "provider" layers (assuming
                            > they're reasonably fast)?

                            You should keep your mocks. If you are using a powerful framework like
                            Rhino Mocks, you can specify that what is important for you in that
                            one test. The rest is stubbed automatically for you.

                            See the difference between CreateMock and DynamicMock in RhinoMocks.
                            Stubs can be created with one line too. It's actually faster to stub
                            with Rhino Mocks than without.

                            Adam
                          Your message has been successfully submitted and would be delivered to recipients shortly.