Skip to content

Instantly share code, notes, and snippets.

@automationhacks
Created February 22, 2020 03:08
Show Gist options
  • Save automationhacks/597a1adbbad1b83460cd04cda20b1e3f to your computer and use it in GitHub Desktop.
Save automationhacks/597a1adbbad1b83460cd04cda20b1e3f to your computer and use it in GitHub Desktop.
Adding BookingTest with cancellation option as well
class SetupTeardownWithDataProvider {
@DataProvider
fun getVehicleTypes(): MutableIterator<Array<Any>> {
val vehicles = arrayListOf<Array<Any>>()
vehicles.add(arrayOf(VehicleType.CAR))
vehicles.add(arrayOf(VehicleType.CAR_XL))
return vehicles.iterator()
}
@Test(dataProvider = "getVehicleTypes")
fun testBookingCreation(vehicleType: VehicleType) {
val booking = Booking()
val orderId = booking.makeBooking(vehicleType)
val isBookingCreated = booking.doesBookingExists(vehicleType, orderId)
Assert.assertNotNull(isBookingCreated)
}
@Test
fun testBookingCancellation() {
val vehicleType = VehicleType.CAR_XL
val booking = Booking()
val orderId = booking.makeBooking(vehicleType)
val isBookingCreated = booking.doesBookingExists(vehicleType, orderId)
Assert.assertNotNull(isBookingCreated)
booking.cancelBooking(vehicleType, orderId)
val isBookingFound = booking.doesBookingExists(vehicleType, orderId)
Assert.assertNotNull(isBookingCreated)
Assert.assertFalse(isBookingFound!!)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment