I\'m failing to mock ResourceBundle.getString()
.
This is my code:
ResourceBundle schemaBundle = Mockito.mock(ResourceBundle.class);
Mockito.
You'll find an example of solution below :
@RunWith(PowerMockRunner.class)
@PrepareForTest({ ResourceBundle.class })
public class ResourceBundleTest {
@Test
public void getStringByPowerMock() throws Exception {
ResourceBundle resourceBundle = PowerMockito.mock(ResourceBundle.class);
Mockito.when(resourceBundle.getString(Mockito.anyString())).thenReturn("Hello world....");
System.out.println(resourceBundle.getString("keyword"));
}
}