Automatic mock instantiation in a Spring JUnit test

纵饮孤独 提交于 2019-11-30 17:52:40

Here is a short article with a code example. A BeanDefinitionRegistryPostProcessor implementation generates a mock object for each lacking bean definition. The generation part is done with a MocksFactory, here is an example for such a factory.

Just in case anyone is still interested in this question, I have extended the code in the article mentioned by Yves Martin with inheritance, support for @Inject, etc... and created a Github project here: https://github.com/rinoto/spring-auto-mock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!