Last active
February 22, 2020 03:26
-
-
Save automationhacks/8a5defa1f6c49c939570be6ba3b0dd5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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