Sunday, May 17, 2020

Sunday, May 3, 2020


//Get Ticket from DB
Ticket ticketFromInDb = ticketBookingDao.findOne(ticketSavedInDb.getTicketId());
assertThat(ticketSavedInDb).isEqualTo(ticketFromInDb);

eg2:-


Iterable allTicketsFromDb = ticketBookingDao.findAll();
List ticketList = new ArrayList<>();

for (Ticket ticket : allTicketsFromDb) {
ticketList.add(ticket);
}
assertThat(ticketList.size()).isEqualTo(2);



Saturday, May 2, 2020

Spring Boot Test Tips

Spring Boot Test:-

1. If You are using h2 (embedded db) for integration testing.Then use following annotation.So,That Spring Boot will not load your main DB.


@RunWith(SpringRunner.class)
@SpringBootTest

@AutoConfigureTestDatabase(connection=EmbeddedDatabaseConnection.H2)


2.Useful tips,You can find in below url

https://www.baeldung.com/spring-boot-testing