Performance: @DataJpaTest for repository testing
MEDIUM IMPACT
This affects test execution speed and resource usage during repository testing in Spring Boot applications.
@DataJpaTest
public class UserRepositoryTest {
@Autowired
private UserRepository userRepository;
@Test
void testFindById() {
// test code
}
}@SpringBootTest
public class UserRepositoryTest {
@Autowired
private UserRepository userRepository;
@Test
void testFindById() {
// test code
}
}| Pattern | Beans Loaded | Test Startup Time | Memory Usage | Verdict |
|---|---|---|---|---|
| @SpringBootTest for repository test | All application beans | 2-5 seconds | High | [X] Bad |
| @DataJpaTest for repository test | Only JPA and Data beans | Under 1 second | Low | [OK] Good |