0

For example, is it necessary to write a Unit test for the following Method:

private PersonRepository personRepository;

@Autowired
public void setPersonRepository(PersonRepository personRepository) {
        this.personRepository = personRepository;
    }

What purpose would the test serve?

alexbt
  • 16,415
  • 6
  • 78
  • 87
java123999
  • 6,974
  • 36
  • 77
  • 121
  • I think it's a good question but I'm pretty sure the linked question covers the situation sufficiently, so I closed as duplicate. – djechlin Jun 28 '16 at 16:14
  • I do not feel that it is a duplicate as it is specific to spring and autowiring? – java123999 Jun 28 '16 at 16:14
  • The *answer* is covered there even if the question is slightly different. If it's not then you need to explain why not and the question can be reopened (e.g. by me). I have enough expertise in Java and unit testing to bet those are the answers you are looking for and they apply to this situation with Spring. – djechlin Jun 28 '16 at 16:21
  • If you want to test if your spring config is working it is probably an integration test, and not a unit test. And if you write an integration test, you are not primarily testing the method but if the `PersonRepository` can be autowired. – user140547 Jun 28 '16 at 16:22

0 Answers0