tag:blogger.com,1999:blog-5691742980190810543.post7829154094995835533..comments2023-10-19T06:16:21.069-07:00Comments on Strats and Tacts: What are mock objects, why do I love them, and why do I use Mockito?Date Haterhttp://www.blogger.com/profile/04451021822445296226noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-5691742980190810543.post-52148074856496780762009-03-17T13:31:00.000-07:002009-03-17T13:31:00.000-07:00Hi Steve Freeman,I agree with you and that was wha...Hi Steve Freeman,<BR/><BR/>I agree with you and that was what I meant to convey but I guess I didn't do it very well. When you consider a <B>Fake</B> object, you've got to implement many things on your own for the purposes of your test: If you want to check how many times a method was called, you have to increment a field. If you want to check the correct parameters were passed, you've got to save the parameters in fields. After you execute the method under test, you check the Fake's <B>STATE</B> to make sure your class collaborates correctly and called the correct methods.<BR/><BR/>So, when I used the word <I>state</I>, I meant <I>how it is called</I>.Date Haterhttps://www.blogger.com/profile/04451021822445296226noreply@blogger.comtag:blogger.com,1999:blog-5691742980190810543.post-43360938904569348962009-03-15T16:02:00.000-07:002009-03-15T16:02:00.000-07:00Great to see you seeing the benefits of mocking, b...Great to see you seeing the benefits of mocking, but I agree with SteveFreeman.<BR/><BR/>Consider the mocks as the supports to the real object in test. Mocks allow you avoid having other real objects that are not related to the test in question. <BR/><BR/>Mocks simulate the expected behavior of external objects the the object(s) being tested.Toolmanhttps://www.blogger.com/profile/00351556847237003891noreply@blogger.comtag:blogger.com,1999:blog-5691742980190810543.post-80233904531208119942009-03-15T13:46:00.000-07:002009-03-15T13:46:00.000-07:00Mockito has some very cool ideas, but I think you'...Mockito has some very cool ideas, but I think you've missed some of the point of Mocks Objects.<BR/><BR/>The significant intent of Mocks is to check how the object under tests relates to its collaborators. A Mock doesn't necessarily check its own state, it checks how it is called.<BR/><BR/>You might want to look into some of the deeper ideas that go with the technique. There's a work in progress description at http://www.mockobjects.com/bookSteve Freemanhttps://www.blogger.com/profile/14771999065792016571noreply@blogger.comtag:blogger.com,1999:blog-5691742980190810543.post-21347269517388885032009-03-12T02:41:00.000-07:002009-03-12T02:41:00.000-07:00After using Easymock and hitting it's limits (lack...After using Easymock and hitting it's limits (lack of mocking static and final classes/methods), I've started to use PowerMock http://code.google.com/p/powermock . It extends EasyMock and Mockito.<BR/><BR/>I recommend it to anyone who starts mocking or is used to work with Easymock.<BR/><BR/>According to the author:<BR/>"PowerMock is not intended to replace other frameworks, rather it can be used in the tricky situations when other frameworks does't allow mocking. PowerMock also contains other useful features such as suppressing static initializers and constructors."<BR/><BR/>Kind regards,<BR/>Bram BruneelBrambohttps://www.blogger.com/profile/15697870125752848298noreply@blogger.comtag:blogger.com,1999:blog-5691742980190810543.post-63553423708160314802009-03-11T13:34:00.000-07:002009-03-11T13:34:00.000-07:00Mockito is great! Check out the slides I put up on...Mockito is great! Check out the slides I put up on its basic usage.<BR/><BR/><A HREF="http://www.rapaul.com/2008/11/19/mocking-in-java-with-mockito/" REL="nofollow">http://www.rapaul.com/2008/11/19/mocking-in-java-with-mockito/</A>Unknownhttps://www.blogger.com/profile/00335907653587988839noreply@blogger.comtag:blogger.com,1999:blog-5691742980190810543.post-39371312721631086012009-03-11T13:33:00.000-07:002009-03-11T13:33:00.000-07:00This comment has been removed by the author.Unknownhttps://www.blogger.com/profile/00335907653587988839noreply@blogger.com