Actually I just read Martin Fowler's article "Mocks aren't stubs" http://www.martinfowler.com/articles/mocksArentStubs.html. It's funny as I think I never used the term "mock" correctly...

The way I understood the concept was: you take an object and you replace it by a proxy: - logical state is obtained by any means consistent with the logical invariants of the object; you can even have "mock" methods that do (almost) nothing...(like failing!)

So okay, maybe in that sense "mock" methods are not pure stubs given that they must at least reach into something that changes the state of an object.

In a way, the "final photo" is: you respect the messaging system, and bluntly change object data. Seems like thermodynamics, many paths are possible (and interesting, depending on what you want to test)

If we focus purely on the external interactions of a program , that particular view that emphasizes state corresponds to treating everything "external" like a database. (In Quantum mechanics this concept is quite close to the concept of "picture" or perspective --Heisenberg picture, Schro"dinger picture, and mixed like the Furry picture-- there testing is the process of getting state but sometimes you want to emphasize the transitions and the "picture" helps then) Then when you start looking for more transparency, and an ORM for example gives you that: the database used is not important anymore; but still the real gain is when you push your abstraction one step further for total transparency: what is left are "datasets" (or set of) with many views (corresponding to different ways of serializing the data). So your database (and the tests!) is say your snapshot of xml before and after any state-changing call... and OO-zealots are just shooting me now;) but hey I still use object-based (black boxes and roles err...interfaces)

hth --stephan

In reply to Re^4: Smallish mock objects by sgt
in thread Smallish mock objects by diotalevi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.