@DataJpaTest

@DataJpaTest tests the persistence layer: it loads only the JPA components (entities, repositories), uses an embedded database by default, and runs each test in a transaction rolled back at the end. It verifies derived queries, @Query queries, and mappings without starting the web layer.

Example

@DataJpaTest
class ClientRepositoryTest {
    @Autowired ClientRepository repo;
}

Related concepts

The whole glossary