Mockito upgrade causes null pointer problems

Posted by Ann Addicks on Stack Overflow See other posts from Stack Overflow or by Ann Addicks
Published on 2012-03-28T15:07:45Z Indexed on 2012/03/29 11:28 UTC
Read the original article Hit count: 256

Filed under:
|

We upgraded from mockito-all-1.8.5.jar to mockito-all-1.9.0.jar and now see null pointers when using annotations for the classes being mocked. Here is an example:

  @Mock
  private static IAccountManager accountManager;
  @Mock
  private static IBusinessUnitManager businessUnitManager;
  private static Gson parser;

@InjectMocks private static DownloadController downloadController;

@BeforeClass public static void setUpBeforeClass() throws Exception { parser = new Gson();

downloadController = new DownloadController(accountManager,
    businessUnitManager, parser);

}

@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); Mockito.reset(accountManager, businessUnitManager); }

As soon as accountManager is referenced in the download controller, it throws a npe. This worked in 1.8.5.

© Stack Overflow or respective owner

Related posts about java

Related posts about mockito