Hacker News new | past | comments | ask | show | jobs | submit login

It's Mockito [1], which has been a standard for a while. There are other libraries and they use different strategies to provide this kind of functionalities (dynamic proxies, bytecode weaving, annotation processing, etc...).

[1] https://site.mockito.org/




And ... is the whole user being mocked or just the method?


It creates a stub, but you can also configure it to pass any method calls to original implementation. You should be tiping your hat i think.

https://javadoc.io/static/org.mockito/mockito-core/3.11.2/or...

User mock = mock(User.java)

Should have been

User mock = mock(User.class)


Ah oops, I've been writing exclusively Kotlin for several years, my Java is becoming rusty (no pun intended).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: