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
@BeforeMethod | |
fun givenBookingIsCreated(testParams: Array<Any>) { | |
val vehicleType = testParams[0] as VehicleType | |
orderId = booking.makeBooking(vehicleType) | |
} |
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)) |
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 { | |
@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() | |
} |
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 { | |
@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() | |
} |
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 { | |
@Test | |
fun testBookingCreation() { | |
val vehicleType = VehicleType.CAR_XL | |
val booking = Booking() | |
val orderId = booking.makeBooking(vehicleType) | |
val isBookingCreated = booking.doesBookingExists(vehicleType, orderId) | |
Assert.assertNotNull(isBookingCreated) |
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
enum class VehicleType() { | |
CAR, | |
CAR_XL | |
} | |
class BookingNotFound(message: String) : Exception(message) | |
class Booking { | |
companion object { |
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
task runTests(type : Test) { | |
useTestNG() { | |
testLogging.showStandardStreams = true | |
listeners << "testFrameworks.testNG.logging.Listener" | |
includeGroups System.getProperty('tag', 'NONE') | |
} | |
} |
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 Listener : TestListenerAdapter() { | |
override fun onStart(context: ITestContext) { | |
Logger.log("Beginning test suite: ${context.outputDirectory}") | |
} | |
override fun onFinish(context: ITestContext?) {} | |
override fun onTestSkipped(result: ITestResult?) {} | |
override fun onTestStart(result: ITestResult) { | |
super.onTestStart(result) |
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
> Task :runTests FAILED | |
Gradle suite > Gradle test > testFrameworks.testNG.logging.LoggingTests.when_CreditedSalary_ShouldBeGreater_ThanBase STANDARD_OUT | |
Checking that credited salary is ok | |
Gradle suite > Gradle test > testFrameworks.testNG.logging.LoggingTests.when_salaryIsNotCredited STANDARD_OUT | |
Checking that salary is not credited | |
Gradle suite > Gradle test > testFrameworks.testNG.logging.LoggingTests.when_salaryIsNotCredited FAILED | |
java.lang.AssertionError at Logging.kt:84 |
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
object Logger { | |
fun log(msg: String, stdOut: Boolean = true) { | |
Reporter.log(msg, stdOut) | |
} | |
} |