Comment AutoWire beans spring lors de l'utilisation de Mockito et Junit?

Je suis en train de configurer ma classe pour être utilisé dans Junit.

Cependant lorsque j'essaie de faire le ci-dessous, j'obtiens un message d'erreur.

Actuel De La Classe De Test:

public class PersonServiceTest {

    @Autowired
    @InjectMocks
    PersonService personService;

    @Before
    public void setUp() throws Exception
    {
        MockitoAnnotations.initMocks(this);
        assertThat(PersonService, notNullValue());

    }

    //tests

Erreur:

org.mockito.exceptions.base.MockitoException: 
Cannot instantiate @InjectMocks field named 'personService'
You haven't provided the instance at field declaration so I tried to construct the instance.
However the constructor or the initialization block threw an exception : null

Comment puis-je résoudre ce problème?

InformationsquelleAutor java123999 | 2016-05-05