vendredi 30 octobre 2015

Mockito creates different instances?

I have an enterprise Java bean with some injected dependencies. I also have a test class which mocks these dependencies with @Mock and @Produces annotations. Everything works fine except that Mockito seems to create different instances for the bean (MyClass@50778) and for the test class (MyClass@50835), therefore verify() calls always fail since all the calls happen on the bean instance and the check is done on the test instance. The most interesting part is that on the continuous integration server the tests run fine, the problem seems to be with my local environment. I see no significant difference between the CI server logs and the output of the local run.

I'm aware that I can't include all of my local preferences, project settings, logs, whatsoever here, so it's hopeless that somebody could blindly point out what the actual problem is here. What I'm looking for is a general guideline... a hint that I could follow to hunt down the problem: what can possibly make Mockito to create different instances for my injected dependency?

Aucun commentaire:

Enregistrer un commentaire