Spring JUnit: How to Mock autowired component in autowired component

前端 未结 6 1521
花落未央
花落未央 2020-12-02 12:20

I\'ve got a Spring component I\'d like to test and this component has an autowired attribute which I need to change for the purpose of unit testing. The problem is, that the

6条回答
  •  悲哀的现实
    2020-12-02 12:25

    You can provide a new testContext.xml in which the @Autowired bean you define is of the type you need for your test.

提交回复
热议问题