Book aBook = mock(Book.class);
when I write to execute
aBook.getClass()
it gives
classcom.tw.model.Book$$EnhancerByMockitoWithCGLIB$$feb29207
But I want : classcom.tw.model.Book
Since Mockito 2.1.0 you can use getMockCreationSettings()
to get details on what was mocked. from the docs
Added the possibility to access the mock creation settings via
Mockito.mockingDetails(mock).getMockCreationSettings()
Here's an example:
@Test
public void aTest() {
Foo mock = Mockito.mock(Foo.class);
MockCreationSettings<?> mockCreationSettings = Mockito.mockingDetails(mock).getMockCreationSettings();
Assert.assertEquals(Foo.class, mockCreationSettings.getTypeToMock());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With