Skip to content

Instantly share code, notes, and snippets.

@pavankjadda
Created December 22, 2021 22:43
Show Gist options
  • Save pavankjadda/de0419052a6e57403ca3aea3432692c2 to your computer and use it in GitHub Desktop.
Save pavankjadda/de0419052a6e57403ca3aea3432692c2 to your computer and use it in GitHub Desktop.
Spring Boot Repository layer unit Test.md
@ExtendWith(SpringExtension.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@ContextConfiguration(classes = {MyApplication.class})
@ImportAutoConfiguration(RefreshAutoConfiguration.class)
@ActiveProfiles(value = "local")
class EmployeeRepositoryTest
{
	@Autowired
	private EmployeeRepository employeeRepository;

	@Test
	void getAllEmployees()
	{
		List<Employee> employeesList=employeeRepository.findAll();
		employeesList.forEach(employee -> System.out.println(employee.getName()));

		assertNotNull(employeesList);
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment