Attila Magyar wrote > I made up an example because it makes easier to talk about this
An easy example which comes up for me a lot is when I want to pretend it's a certain DateAndTime. I'd like DateAndTime now to return a canned value. I know all the theoretical arguments about how if I change my domain object to really get the date from an atomic clock server, or a serial port light sensor connected to a sun dial, my test will fail because I've tied it to a duplicated implementation detail. However, I'm willing to accept that risk because: - in 5 years, I've only ever queried the current timestamp via "DateAndTime now" - the duplication can be controlled via abstraction e.g. MyTestCase>>#now: aDateAndTime - writing (pseudo-code) "DateAndTime can receive:#now; answers: aDateAndTime": - is extremely easy - precludes me from muddying my domain class with a lot of test-only hooks, like #clock: and #clock or #clockClass: and #clockClass (multiplied by all such vectors) For sure, there are times when this could be abused. But the spirit of Smalltalk is to trust the programmer with the full power of the computer at every level (e.g. private methods are only a suggestion). ----- Cheers, Sean -- View this message in context: http://forum.world.st/ANN-BabyMock-2-tp4748530p4756202.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.