Related questions
Mockito + PowerMock LinkageError while mocking system class
I've got such a code snippet:
@RunWith(PowerMockRunner.class)
@PrepareForTest({Thread.class})
public class AllMeasuresDataTest {
@Before
public void setUp() throws Exception {
}
@Test
public void testGetMeasures() {
AllMeasuresData measure = new AllMeasuresData();
assertEquals(measure.getMeasures(), null);
HashMap<String, Measure> map = new …
PowerMock throws NoSuchMethodError (setMockName)
I'm trying to mock a constructor using PowerMockito but every time I run the test I get the following error:
java.lang.NoSuchMethodError: org.mockito.internal.creation.MockSettingsImpl.setMockName(Lorg/mockito/mock/MockName;)Lorg/mockito/internal/creation/settings/CreationSettings;
at …
What do I use instead of Whitebox in Mockito 2.2 to set fields?
When using Mockito 1.9.x I have been using Whiteboxto set values of fields to "inject" mocks. Se example below:
@Before
public void setUp() {
eventHandler = new ProcessEventHandler();
securityService = new SecurityServiceMock();
registrationService = mock(RegistrationService.class);
Whitebox.setInternalState(eventHandler, "registrationService", registrationService);
Whitebox.setInternalState(…