Mockito upgrade causes null pointer problems
- by Ann Addicks
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.