tag:blogger.com,1999:blog-8779027097922009803.post1688810771873577999..comments2023-08-16T04:59:05.497-07:00Comments on Share your knowledge: Unit testing with MockitoAnonymoushttp://www.blogger.com/profile/08988603608690509267noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-8779027097922009803.post-26069747785777948722013-09-10T09:10:03.620-07:002013-09-10T09:10:03.620-07:00yes... in the above case it might be overkill as ...yes... in the above case it might be overkill as they are always called of course. But if you conditionally use services you are completely right and your remark is more than valid.Anonymoushttps://www.blogger.com/profile/08988603608690509267noreply@blogger.comtag:blogger.com,1999:blog-8779027097922009803.post-28262314864707641582013-09-10T08:48:52.188-07:002013-09-10T08:48:52.188-07:00Yay, test code :)
When I use mocks, I also verify ...Yay, test code :)<br />When I use mocks, I also verify that they are called in the test.<br /><br />Example:<br />verify(temperatureService).predictTemperature(any(Date.class), any(Coordinates.class));<br /><br />After refactoring you'll find out whether your mock is still needed or you accidentally introduced an extra call for this method.Jasha Joachimsthalhttps://www.blogger.com/profile/16322353868709089488noreply@blogger.com