Skip to content

Instantly share code, notes, and snippets.

@automationhacks
Last active February 22, 2020 03:26
Show Gist options
  • Save automationhacks/8a5defa1f6c49c939570be6ba3b0dd5f to your computer and use it in GitHub Desktop.
Save automationhacks/8a5defa1f6c49c939570be6ba3b0dd5f to your computer and use it in GitHub Desktop.
class SetupTeardownWithDataProvider {
private lateinit var vehicleType: VehicleType
private lateinit var orderId: String
private val booking = Booking()
@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()
}
@BeforeMethod
fun givenBookingIsCreated(vehicleType: VehicleType) {
orderId = booking.makeBooking(vehicleType)
}
@Test(dataProvider = "getVehicleTypes")
fun testBookingCreation(vehicleType: VehicleType) {
val isBookingCreated = booking.doesBookingExists(vehicleType, orderId)
Assert.assertNotNull(isBookingCreated)
}
@Test(dataProvider = "getVehicleTypes")
fun testBookingCancellation(vehicleType: 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