Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@ContextConfiguration(classes = { HotelApplication.class }, initializers = ITCustomerJUnit5Repo.Initializer.class)
@DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD)
@TestMethodOrder(OrderAnnotation.class)
public class ITCustomerJUnit5Repo {
//Removed code, for clarity
@Test
@Order(1)
public void testCountNumberOfCustomersInDB() {
assertEquals(2, repo.count());
}
@Test
public void testRetrieveCustomerFromDatabase() {
Customer customer = repo.findAll().iterator().next();
assertEquals("John", customer.getFirstName());
assertEquals("Doe", customer.getLastName());
assertEquals("Middle", customer.getMiddleName());
assertEquals("", customer.getSuffix());
}
@Test
public void testAddCustomerToDB() throws ParseException {
Customer customer = new Customer.CustomerBuilder().firstName("BoJack").middleName("Horse").lastName("Horseman")
.suffix("Sr.").build();
repo.save(customer);
assertEquals(3, repo.count());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment