in reply to Re^3: Smallish mock objects
in thread Smallish mock objects
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Smallish mock objects
by adrianh (Chancellor) on Dec 23, 2006 at 11:57 UTC | |
by sgt (Deacon) on Dec 23, 2006 at 15:01 UTC |