Meu código de teste
package br.com.alura.forum.repository;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.context.junit4.SpringRunner;
import br.com.alura.forum.modelo.Curso;
@RunWith(SpringRunner.class)
@DataJpaTest()
public class CursoRepositoryTest {
@Autowired
private CursoRepository cursoRepository;
@Test
public void buscaCursoPeloNome() {
String nomeCurso = "HTML 5";
Curso curso = cursoRepository.findByNome(nomeCurso);
Assert.assertNotNull(curso);
Assert.assertEquals(nomeCurso, curso.getNome());
}
}
Minha pilha de exception
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration'
Caused by: java.lang.IllegalStateException: Failed to replace DataSource with an embedded database for tests. If you want an embedded database please put a supported one on the classpath or tune the replace attribute of @AutoConfigureTestDatabase.
Será que o erro é por conta de eu estar usando o MySql