dimanche 18 juin 2017

DataJpaTest - how to configure

http://ift.tt/209xCts I found here examples of testing repositories:

@RunWith(SpringRunner.class)
@DataJpaTest
public class ExampleRepositoryTests {

@Autowired
private TestEntityManager entityManager;

@Autowired
private UserRepository repository;

@Test
public void testExample() throws Exception {
    this.entityManager.persist(new User("sboot", "1234"));
    User user = this.repository.findByUsername("sboot");
    assertThat(user.getUsername()).isEqualTo("sboot");
    assertThat(user.getVin()).isEqualTo("1234");
}

}

But I don't know how to configure it for my project. I use SpringBoot and PostgreSQL database.

Aucun commentaire:

Enregistrer un commentaire