Teste de primavera e maven

Estou tentando testar meu aplicativo Web Spring, mas tenho alguns problemas.

Eu adicionei uma aula de teste no meu maven

@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration
public class UserServiceTest {

    @Autowired
    private UserService userService;

    @Test
    public void testName() throws Exception {
        List<UserEntity> userEntities = userService.getAllUsers();

        Assert.assertNotNull(userEntities);
    }
}

Mas eu tenho umNullPointerException em userService quando tento executar este teste. IntelliJ diz "Não foi possível conectar automaticamente. Nenhum bean do tipo 'UserService' foi encontrado. Após adicionar@RunWith(SpringJUnit4ClassRunner.class) , eu tenho essa exceção

java.lang.IllegalStateException: Neither GenericXmlContextLoader nor AnnotationConfigContextLoader was able to detect defaults, and no ApplicationContextInitializers were declared for context configuration

Como posso resolver isso? E acho que preciso executar esse teste no meu servidor tomcat, mas como posso implantar para testar com o IntelliJ? (como o comando 'mvn clean install tomcat7: run-war-only')

questionAnswers(3)

yourAnswerToTheQuestion