Add method mockAutowired and getBean to auto mock Autowired fields, then it will be easy when mock some complex server with many Autowired fields.It's a new feature.

Comment From: pivotal-issuemaster

@boroborome Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: pivotal-issuemaster

@boroborome Thank you for signing the Contributor License Agreement!

Comment From: snicoll

@boroborome please create a Jira issue for this change.

Comment From: boroborome

@snicoll I don't known where to create a issue.please give me a link?

Comment From: snicoll

Sure, here.

Comment From: boroborome

This is the issue number : SPR-16355

Comment From: sbrannen

Hi @boroborome,

Thanks for submitting your first PR to the Spring Framework, and sorry for taking so long to get back to you.

After reviewing your proposal, the team has decided not to introduce this support in ReflectionTestUtils.

In general, we recommend that @Autowired dependencies be injected via constructors or setter methods. This allows the dependencies to be supplied in tests without the need for ReflectionTestUtils.

For unit tests, if you wish to mock those dependencies easily, you may find the @Mock and @InjectMocks annotations from Mockito useful.

For integration tests with Spring Boot, you may find the @MockBean and @SpyBean annotations useful.

In light of the above, we are closing this PR.