title: Mocking objects in JUnit tests - best practice?
body: <p>Do you think mocking objects in JUnit test is a bests practice? I don't see the big advantage. Sure if you have a database which should not be considered in your test it makes sense, but why isn't just injected an other implementation of that component (if spring is used). An object factory for the tests would make this much easy. I don't have much experience (we are using Mockito), but I've already seen, that application code gets modified so that some properties gets mockable! Test cases should never efford such changes in productive code in my oppinion.</p>
  
  <p>So what do you think of this topic? In which cases do you are mocking your object or why you don't?</p>