How to use then method of io.kotest.core.spec.style.scopes.BehaviorSpecGivenContainerScope class

Best Kotest code snippet using io.kotest.core.spec.style.scopes.BehaviorSpecGivenContainerScope.then

MovieDetailsSpec.kt

Source:MovieDetailsSpec.kt Github

copy

Full Screen

1package com.krzykrucz.fastfurious.module.moviedetails2import com.krzykrucz.fastfurious.monolith.IntegrationEvent3import com.krzykrucz.fastfurious.support.GivenApp4import com.krzykrucz.fastfurious.support.KtorModuleTestSupport5import io.kotest.assertions.ktor.shouldHaveContent6import io.kotest.assertions.timing.eventually7import io.kotest.core.spec.style.BehaviorSpec8import io.kotest.core.spec.style.scopes.BehaviorSpecGivenContainerScope9import io.ktor.application.Application10import io.ktor.http.HttpMethod.Companion.Get11import io.ktor.server.testing.TestApplicationEngine12import io.ktor.server.testing.handleRequest13import kotlinx.coroutines.delay14import java.time.Duration15import java.time.Instant16import java.time.LocalDate17import java.time.Month.JUNE18import java.util.UUID19class MovieDetailsSpec : BehaviorSpec({20 `Given movie details app`(" and movie is added to catalog") { app ->21 app.movieIsAddedToCatalog(22 id = "tt0463985",23 title = "The Fast and the Furious: Tokyo Drift",24 description = "description",25 releaseDate = LocalDate.of(2006, JUNE, 16),26 runtime = Duration.ofMinutes(104),27 imdbRating = 6.128 )29 When("all details are fetched") {30 eventually {31 val response = app.handleRequest(Get, "/details").response32 Then("one movie details with no rating") {33 // language=JSON34 response shouldHaveContent """[{35 |"id":"tt0463985",36 |"title":"The Fast and the Furious: Tokyo Drift",37 |"description":"description",38 |"releaseDate":"2006-06-16",39 |"rating":"0.0",40 |"votes":"0",41 |"imdbRating":"6.1",42 |"runtime":"104 min"43 |}]""".trimMargin().toSingleLine()44 }45 }46 }47 }48 `Given movie details app`(" and movie is rated") { app ->49 app.movieIsAddedToCatalog(50 id = "tt0463985",51 title = "The Fast and the Furious: Tokyo Drift",52 description = "description",53 releaseDate = LocalDate.of(2006, JUNE, 16),54 runtime = Duration.ofMinutes(104),55 imdbRating = 6.156 )57 app.movieIsRated(58 id = "tt0463985",59 votesCount = 11,60 averageRating = 6.5161 )62 When("all details are fetched") {63 eventually {64 val response = app.handleRequest(Get, "/details").response65 Then("one movie details with rating updated") {66 // language=JSON67 response shouldHaveContent """[{68 |"id":"tt0463985",69 |"title":"The Fast and the Furious: Tokyo Drift",70 |"description":"description",71 |"releaseDate":"2006-06-16",72 |"rating":"6.5",73 |"votes":"11",74 |"imdbRating":"6.1",75 |"runtime":"104 min"76 |}]""".trimMargin().toSingleLine()77 }78 }79 }80 }81 `Given movie details app`(" and movie rated event is duplicated") { app ->82 app.movieIsAddedToCatalog(83 id = "tt0463985",84 title = "The Fast and the Furious: Tokyo Drift",85 description = "description",86 releaseDate = LocalDate.of(2006, JUNE, 16),87 runtime = Duration.ofMinutes(104),88 imdbRating = 6.189 )90 val eventId = UUID.randomUUID().toString()91 app.movieIsRated(92 eventId = eventId,93 id = "tt0463985",94 votesCount = 11,95 averageRating = 6.5196 )97 app.movieIsRated(98 eventId = eventId,99 id = "tt0463985",100 votesCount = 11,101 averageRating = 6.51102 )103 When("all details are fetched") {104 eventually {105 val response = app.handleRequest(Get, "/details").response106 Then("one movie details with rating updated") {107 // language=JSON108 response shouldHaveContent """[{109 |"id":"tt0463985",110 |"title":"The Fast and the Furious: Tokyo Drift",111 |"description":"description",112 |"releaseDate":"2006-06-16",113 |"rating":"6.5",114 |"votes":"11",115 |"imdbRating":"6.1",116 |"runtime":"104 min"117 |}]""".trimMargin().toSingleLine()118 }119 }120 }121 }122 `Given movie details app`(" and movie is rated twice") { app ->123 app.movieIsAddedToCatalog(124 id = "tt0463985",125 title = "The Fast and the Furious: Tokyo Drift",126 description = "description",127 releaseDate = LocalDate.of(2006, JUNE, 16),128 runtime = Duration.ofMinutes(104),129 imdbRating = 6.1130 )131 app.movieIsRated(132 id = "tt0463985",133 votesCount = 11,134 averageRating = 6.51135 )136 delay(50)137 app.movieIsRated(138 id = "tt0463985",139 votesCount = 12,140 averageRating = 5.1141 )142 When("all details are fetched") {143 eventually {144 val response = app.handleRequest(Get, "/details").response145 Then("one movie details with rating updated") {146 // language=JSON147 response shouldHaveContent """[{148 |"id":"tt0463985",149 |"title":"The Fast and the Furious: Tokyo Drift",150 |"description":"description",151 |"releaseDate":"2006-06-16",152 |"rating":"5.1",153 |"votes":"12",154 |"imdbRating":"6.1",155 |"runtime":"104 min"156 |}]""".trimMargin().toSingleLine()157 }158 }159 }160 }161 `Given movie details app`(" and movie is rated twice in wrong order") { app ->162 app.movieIsAddedToCatalog(163 id = "tt0463985",164 title = "The Fast and the Furious: Tokyo Drift",165 description = "description",166 releaseDate = LocalDate.of(2006, JUNE, 16),167 runtime = Duration.ofMinutes(104),168 imdbRating = 6.1169 )170 app.movieIsRated(171 id = "tt0463985",172 votesCount = 12,173 averageRating = 5.1174 )175 delay(50)176 app.movieIsRated(177 id = "tt0463985",178 votesCount = 11,179 averageRating = 6.51180 )181 When("all details are fetched") {182 eventually {183 val response = app.handleRequest(Get, "/details").response184 Then("one movie details with rating not updated") {185 // language=JSON186 response shouldHaveContent """[{187 |"id":"tt0463985",188 |"title":"The Fast and the Furious: Tokyo Drift",189 |"description":"description",190 |"releaseDate":"2006-06-16",191 |"rating":"5.1",192 |"votes":"12",193 |"imdbRating":"6.1",194 |"runtime":"104 min"195 |}]""".trimMargin().toSingleLine()196 }197 }198 }199 }200}) {201 override fun listeners() = listOf(ktor)202}203private fun TestApplicationEngine.movieIsAddedToCatalog(204 id: String,205 title: String,206 description: String,207 releaseDate: LocalDate,208 runtime: Duration,209 imdbRating: Double210) {211 environment.monitor.raise(212 IntegrationEvent.MovieAddedToCatalogEvent,213 IntegrationEvent.MovieAddedToCatalogEvent(214 id = id,215 imdbId = id,216 title = title,217 description = description,218 releaseDate = releaseDate,219 imdbRating = imdbRating,220 imdbVotes = 259_218,221 runtime = runtime,222 timestamp = anyTime223 )224 )225}226private fun TestApplicationEngine.movieIsRated(227 id: String,228 votesCount: Int,229 averageRating: Double,230 eventId: String = UUID.randomUUID().toString()231) {232 environment.monitor.raise(233 IntegrationEvent.MovieRatedEvent,234 IntegrationEvent.MovieRatedEvent(235 id = eventId,236 movieId = id,237 newAverageRating = averageRating,238 newVotesCount = votesCount,239 timestamp = anyTime240 )241 )242}243private fun BehaviorSpec.`Given movie details app`(244 name: String,245 test: suspend BehaviorSpecGivenContainerScope.(TestApplicationEngine) -> Unit246) = GivenApp("ratings app $name", ktor.moduleTestApp, test)247private val ktor = KtorModuleTestSupport(Application::movieDetailsModule, Unit)248private val anyTime = Instant.parse("2007-12-03T10:15:30.00Z")249private fun String.toSingleLine() =250 replace("[\n\r]".toRegex(), "")...

Full Screen

Full Screen

CatalogSpec.kt

Source:CatalogSpec.kt Github

copy

Full Screen

1package com.krzykrucz.fastfurious.module.catalog2import com.krzykrucz.fastfurious.monolith.IntegrationEvent.MovieAddedToCatalogEvent3import com.krzykrucz.fastfurious.support.GivenApp4import com.krzykrucz.fastfurious.support.KtorModuleTestSupport5import com.krzykrucz.fastfurious.support.OMDbApiMockTestSupport6import io.kotest.core.spec.style.BehaviorSpec7import io.kotest.core.spec.style.scopes.BehaviorSpecGivenContainerScope8import io.ktor.application.Application9import io.ktor.server.testing.TestApplicationEngine10import java.time.Clock11import java.time.Duration12import java.time.Instant13import java.time.LocalDate14import java.time.Month.APRIL15import java.time.Month.JUNE16import java.time.Month.MAY17import java.time.ZoneId18class CatalogSpec : BehaviorSpec({19 `Given catalog app`("") { app ->20 When("app is running") {21 Then("all movies are downloaded once") {22 omdbApiMock.verifyAllMoviesDownloadedOnce()23 }24 Then("all Fast&Furious movies are added to the catalog") {25 ktor.eventsShouldBePublished(26 MovieAddedToCatalogEvent(27 id = "tt0232500",28 imdbId = "tt0232500",29 title = "The Fast and the Furious",30 description = "Los Angeles police officer Brian O'Conner must decide where his loyalty really lies when he becomes enamored with the street racing world he has been sent undercover to destroy.",31 releaseDate = LocalDate.of(2001, JUNE, 22),32 imdbRating = 6.8,33 imdbVotes = 370_116,34 runtime = Duration.ofMinutes(106),35 timestamp = currentTime36 ),37 MovieAddedToCatalogEvent(38 id = "tt0322259",39 imdbId = "tt0322259",40 title = "2 Fast 2 Furious",41 description = "Former cop Brian O'Conner is called upon to bust a dangerous criminal and he recruits the help of a former childhood friend and street racer who has a chance to redeem himself.",42 releaseDate = LocalDate.of(2003, JUNE, 6),43 imdbRating = 5.9,44 imdbVotes = 264_489,45 runtime = Duration.ofMinutes(107),46 timestamp = currentTime47 ),48 MovieAddedToCatalogEvent(49 id = "tt0463985",50 imdbId = "tt0463985",51 title = "The Fast and the Furious: Tokyo Drift",52 description = "A teenager becomes a major competitor in the world of drift racing after moving in with his father in Tokyo to avoid a jail sentence in America.",53 releaseDate = LocalDate.of(2006, JUNE, 16),54 imdbRating = 6.0,55 imdbVotes = 259_218,56 runtime = Duration.ofMinutes(104),57 timestamp = currentTime58 ),59 MovieAddedToCatalogEvent(60 id = "tt1013752",61 imdbId = "tt1013752",62 title = "Fast & Furious",63 description = "Brian O'Conner, back working for the FBI in Los Angeles, teams up with Dominic Toretto to bring down a heroin importer by infiltrating his operation.",64 releaseDate = LocalDate.of(2009, APRIL, 3),65 imdbRating = 6.6,66 imdbVotes = 276_684,67 runtime = Duration.ofMinutes(107),68 timestamp = currentTime69 ),70 MovieAddedToCatalogEvent(71 id = "tt1596343",72 imdbId = "tt1596343",73 title = "Fast Five",74 description = "Dominic Toretto and his crew of street racers plan a massive heist to buy their freedom while in the sights of a powerful Brazilian drug lord and a dangerous federal agent.",75 releaseDate = LocalDate.of(2011, APRIL, 29),76 imdbRating = 7.3,77 imdbVotes = 368_801,78 runtime = Duration.ofMinutes(130),79 timestamp = currentTime80 ),81 MovieAddedToCatalogEvent(82 id = "tt1905041",83 imdbId = "tt1905041",84 title = "Fast & Furious 6",85 description = "Hobbs has Dominic and Brian reassemble their crew to take down a team of mercenaries: Dominic unexpectedly gets sidetracked with facing his presumed deceased girlfriend, Letty.",86 releaseDate = LocalDate.of(2013, MAY, 24),87 imdbRating = 7.0,88 imdbVotes = 383_258,89 runtime = Duration.ofMinutes(130),90 timestamp = currentTime91 ),92 MovieAddedToCatalogEvent(93 id = "tt2820852",94 imdbId = "tt2820852",95 title = "Furious 7",96 description = "Deckard Shaw seeks revenge against Dominic Toretto and his family for his comatose brother.",97 releaseDate = LocalDate.of(2015, APRIL, 3),98 imdbRating = 7.1,99 imdbVotes = 376_958,100 runtime = Duration.ofMinutes(137),101 timestamp = currentTime102 ),103 MovieAddedToCatalogEvent(104 id = "tt4630562",105 imdbId = "tt4630562",106 title = "The Fate of the Furious",107 description = "When a mysterious woman seduces Dominic Toretto into the world of terrorism and a betrayal of those closest to him, the crew face trials that will test them as never before.",108 releaseDate = LocalDate.of(2017, APRIL, 14),109 imdbRating = 6.6,110 imdbVotes = 221_120,111 runtime = Duration.ofMinutes(136),112 timestamp = currentTime113 ),114 MovieAddedToCatalogEvent(115 id = "tt5433138",116 imdbId = "tt5433138",117 title = "F9: The Fast Saga",118 description = "Dom and the crew must take on an international terrorist who turns out to be Dom and Mia's estranged brother.",119 releaseDate = LocalDate.of(2021, JUNE, 25),120 imdbRating = 5.2,121 imdbVotes = 106_141,122 runtime = Duration.ofMinutes(143),123 timestamp = currentTime124 ),125 )126 }127 }128 }129}) {130 override fun listeners() = listOf(omdbApiMock, ktor)131}132private fun BehaviorSpec.`Given catalog app`(133 name: String,134 test: suspend BehaviorSpecGivenContainerScope.(TestApplicationEngine) -> Unit135) = GivenApp("ratings app $name", ktor.moduleTestApp, test)136private val currentTime = Instant.parse("2007-12-03T10:15:30.00Z")137private val omdbApiMock = OMDbApiMockTestSupport()138private val testConfig = catalogConfig {139 clock = Clock.fixed(currentTime, ZoneId.systemDefault())140 omdbApiKey = omdbApiMock.apiKey141 omdbBaseUrl = omdbApiMock.baseUrl142}143private val ktor = KtorModuleTestSupport(Application::catalogModule, testConfig)...

Full Screen

Full Screen

RatingsSpec.kt

Source:RatingsSpec.kt Github

copy

Full Screen

1package com.krzykrucz.fastfurious.module.ratings2import com.krzykrucz.fastfurious.module.ratings.infrastructure.UUIDProvider3import com.krzykrucz.fastfurious.monolith.IntegrationEvent4import com.krzykrucz.fastfurious.support.GivenApp5import com.krzykrucz.fastfurious.support.KtorModuleTestSupport6import io.kotest.assertions.ktor.shouldHaveContent7import io.kotest.assertions.ktor.shouldHaveStatus8import io.kotest.core.spec.Spec9import io.kotest.core.spec.style.BehaviorSpec10import io.kotest.core.spec.style.scopes.BehaviorSpecGivenContainerScope11import io.ktor.application.Application12import io.ktor.http.HttpMethod13import io.ktor.http.HttpStatusCode14import io.ktor.server.testing.TestApplicationEngine15import io.ktor.server.testing.handleRequest16import io.mockk.every17import io.mockk.mockk18import java.time.Clock19import java.time.Duration20import java.time.Instant21import java.time.LocalDate22import java.time.Month23import java.time.ZoneId24import java.util.UUID25class RatingsSpec : BehaviorSpec({26 `Given ratings app`(" and movies $someMovieId and $anotherMovieId are added to catalog") { app ->27 app.movieIsAddedToCatalog(someMovieId)28 app.movieIsAddedToCatalog(anotherMovieId)29 When("movie $someMovieId is rated") {30 val response = app.handleRequest(HttpMethod.Post, "/rate/$someMovieId/10").response31 Then("response status is ok") {32 response shouldHaveStatus HttpStatusCode.OK33 }34 Then("movie rated event is published") {35 ktor.eventShouldBePublished(36 IntegrationEvent.MovieRatedEvent(37 id = firstUUID.toString(),38 movieId = someMovieId,39 newAverageRating = 10.0,40 newVotesCount = 1,41 timestamp = currentTime42 )43 )44 }45 }46 When("movie $anotherMovieId is rated") {47 val response = app.handleRequest(HttpMethod.Post, "/rate/$someMovieId/5").response48 Then("response status is ok") {49 response shouldHaveStatus HttpStatusCode.OK50 }51 Then("movie rated event is published") {52 ktor.eventShouldBePublished(53 IntegrationEvent.MovieRatedEvent(54 id = secondUUID.toString(),55 movieId = someMovieId,56 newAverageRating = 7.5,57 newVotesCount = 2,58 timestamp = currentTime59 )60 )61 }62 }63 When("there is a call with invalid movie id") {64 val response = app.handleRequest(HttpMethod.Post, "/rate/f$someMovieId/5").response65 Then("response status is bad request") {66 response shouldHaveStatus HttpStatusCode.BadRequest67 response shouldHaveContent "movie id param is invalid"68 }69 }70 }71 `Given ratings app`(" and empty catalog") { app ->72 When("there is a call with invalid rating") {73 val response = app.handleRequest(HttpMethod.Post, "/rate/$unknownMovieId/10").response74 Then("response status is 5xx") {75 response shouldHaveStatus HttpStatusCode.InternalServerError76 response shouldHaveContent "NoSuchMovie"77 }78 Then("no events are published") {79 ktor.noEventsShouldBePublished()80 }81 }82 }83}) {84 override fun listeners() = listOf(ktor)85 override fun beforeSpec(spec: Spec) {86 super.beforeSpec(spec)87 every { uuidProvider() } returnsMany listOf(firstUUID, secondUUID)88 }89}90private fun TestApplicationEngine.movieIsAddedToCatalog(id: String) {91 environment.monitor.raise(92 IntegrationEvent.MovieAddedToCatalogEvent,93 IntegrationEvent.MovieAddedToCatalogEvent(94 id = id,95 imdbId = id,96 title = "The Fast and the Furious: Tokyo Drift",97 description = "A teenager becomes a major competitor in the world of drift racing after moving in with his father in Tokyo to avoid a jail sentence in America.",98 releaseDate = LocalDate.of(2006, Month.JUNE, 16),99 imdbRating = 6.0,100 imdbVotes = 259_218,101 runtime = Duration.ofMinutes(104),102 timestamp = currentTime - Duration.ofSeconds(1)103 )104 )105}106private val currentTime = Instant.parse("2007-12-03T10:15:30.00Z")107private const val someMovieId = "tt0463985"108private const val anotherMovieId = "tt1013752"109private const val unknownMovieId = "tt1905041"110private val firstUUID = UUID.fromString("b236a1b3-923d-42b1-a872-2eb1a2f8ef5d")111private val secondUUID = UUID.fromString("c0a0eff8-0b19-40ec-8286-a0ec712cdd39")112private val uuidProvider = mockk<UUIDProvider>()113private val testConfig = RatingsConfig(114 clock = Clock.fixed(currentTime, ZoneId.systemDefault()),115 uuidProvider = uuidProvider116)117private val ktor = KtorModuleTestSupport(Application::ratingsModule, testConfig)118private fun BehaviorSpec.`Given ratings app`(119 name: String,120 test: suspend BehaviorSpecGivenContainerScope.(TestApplicationEngine) -> Unit121) = GivenApp("ratings app $name", ktor.moduleTestApp, test)...

Full Screen

Full Screen

ShowtimesSpec.kt

Source:ShowtimesSpec.kt Github

copy

Full Screen

1package com.krzykrucz.fastfurious.module.showtimes2import com.krzykrucz.fastfurious.monolith.IntegrationEvent3import com.krzykrucz.fastfurious.support.GivenApp4import com.krzykrucz.fastfurious.support.KtorModuleTestSupport5import io.kotest.assertions.json.shouldMatchJson6import io.kotest.assertions.ktor.shouldHaveStatus7import io.kotest.core.spec.IsolationMode8import io.kotest.core.spec.style.BehaviorSpec9import io.kotest.core.spec.style.scopes.BehaviorSpecGivenContainerScope10import io.kotest.matchers.string.shouldMatch11import io.ktor.application.Application12import io.ktor.http.HttpMethod13import io.ktor.http.HttpStatusCode.Companion.OK14import io.ktor.server.testing.TestApplicationEngine15import io.ktor.server.testing.handleRequest16import io.ktor.server.testing.setBody17import java.time.Clock18import java.time.Duration19import java.time.Instant20import java.time.LocalDate21import java.time.Month22import java.time.ZoneId23class ShowtimesSpec : BehaviorSpec({24 `Given showtimes app`(" and movie $someMovieTitle is added to catalog") { app ->25 app.movieIsAddedToCatalog(someMovieTitle)26 var showId: String? = null27 When("show is created") {28 val response = app.handleRequest(HttpMethod.Post, "/showtimes/schedule") {29 addHeader("Content-Type", "application/json")30 setBody(31 """32 {33 "title": "$someMovieTitle",34 "showTime": "$showTime",35 "runtime": "$anyRuntime",36 "price": "$price"37 }38 """.trimIndent()39 )40 }.response41 Then("response status is ok") {42 response shouldHaveStatus OK43 response.content shouldMatch "([a-f0-9]{8}(-[a-f0-9]{4}){4}[a-f0-9]{8})".toRegex()44 showId = response.content45 }46 Then("showtimes view contains this show") {47 val view = app.handleRequest(HttpMethod.Get, "/showtimes").response48 view shouldHaveStatus OK49 view.content shouldMatchJson """50 [51 {52 "day": "2007-12-04",53 "showtimes": {54 "The Fast and the Furious: Tokyo Drift": [55 "2007-12-04T11:15:30"56 ]57 }58 }59 ]60 """.trimIndent()61 }62 }63 When("show is updated") {64 val response = app.handleRequest(HttpMethod.Put, "/showtimes/schedule/$showId") {65 addHeader("Content-Type", "application/json")66 setBody(67 """68 {69 "startTime": "$showTimeHourLater",70 "price": "$priceDollarBigger"71 }""".trimIndent()72 )73 }.response74 Then("response status is ok") {75 response shouldHaveStatus OK76 }77 Then("showtimes view contains updated show") {78 val view = app.handleRequest(HttpMethod.Get, "/showtimes").response79 view shouldHaveStatus OK80 view.content shouldMatchJson """81 [82 {83 "day": "2007-12-04",84 "showtimes": {85 "The Fast and the Furious: Tokyo Drift": [86 "2007-12-04T12:15:30"87 ]88 }89 }90 ]91 """.trimIndent()92 }93 }94 }95}) {96 override fun listeners() = listOf(ktor)97 override fun isolationMode() = IsolationMode.SingleInstance98}99private fun TestApplicationEngine.movieIsAddedToCatalog(title: String) {100 environment.monitor.raise(101 IntegrationEvent.MovieAddedToCatalogEvent,102 IntegrationEvent.MovieAddedToCatalogEvent(103 id = "tt0463985",104 imdbId = "tt0463985",105 title = title,106 description = "A teenager becomes a major competitor in the world of drift racing after moving in with his father in Tokyo to avoid a jail sentence in America.",107 releaseDate = LocalDate.of(2006, Month.JUNE, 16),108 imdbRating = 6.0,109 imdbVotes = 259_218,110 runtime = Duration.ofMinutes(104),111 timestamp = currentTime - Duration.ofSeconds(1)112 )113 )114}115private val currentTime = Instant.parse("2007-12-03T10:15:30.00Z")116private const val someMovieTitle = "The Fast and the Furious: Tokyo Drift"117private const val anyRuntime = "PT1h"118private const val price = "11.54"119private const val priceDollarBigger = "12.54"120private const val showTime = "2007-12-04T11:15:30.00"121private const val showTimeHourLater = "2007-12-04T12:15:30.00"122private val testClock = Clock.fixed(currentTime, ZoneId.systemDefault())123private val ktor = KtorModuleTestSupport(Application::showtimesModule, testClock)124private fun BehaviorSpec.`Given showtimes app`(125 name: String,126 test: suspend BehaviorSpecGivenContainerScope.(TestApplicationEngine) -> Unit127) = GivenApp("showtimes app $name", ktor.moduleTestApp, test)...

Full Screen

Full Screen

BehaviorSpecGivenContainerScope.kt

Source:BehaviorSpecGivenContainerScope.kt Github

copy

Full Screen

...15 * xwhen("some disabled test").config(...)16 *17 * and18 *19 * then("some test")20 * then("some test").config(...)21 * xthen("some disabled test").config(...)22 * xthen("some disabled test").config(...)23 *24 */25@Suppress("FunctionName")26@KotestTestScope27class BehaviorSpecGivenContainerScope(28 val testScope: TestScope,29) : AbstractContainerScope(testScope) {30 suspend fun And(name: String, test: suspend BehaviorSpecGivenContainerScope.() -> Unit) =31 addAnd(name, test, xdisabled = false)32 suspend fun and(name: String, test: suspend BehaviorSpecGivenContainerScope.() -> Unit) =33 addAnd(name, test, xdisabled = false)34 suspend fun xand(name: String, test: suspend BehaviorSpecGivenContainerScope.() -> Unit) =35 addAnd(name, test, xdisabled = true)36 suspend fun xAnd(name: String, test: suspend BehaviorSpecGivenContainerScope.() -> Unit) =37 addAnd(name, test, xdisabled = true)38 private suspend fun addAnd(39 name: String,40 test: suspend BehaviorSpecGivenContainerScope.() -> Unit,41 xdisabled: Boolean42 ) {43 registerContainer(TestName("And: ", name, true), xdisabled, null) {44 BehaviorSpecGivenContainerScope(this).test()45 }46 }47 suspend fun When(name: String, test: suspend BehaviorSpecWhenContainerScope.() -> Unit) = addWhen(name, test, xdisabled = false)48 suspend fun `when`(name: String, test: suspend BehaviorSpecWhenContainerScope.() -> Unit) = addWhen(name, test, xdisabled = false)49 suspend fun xwhen(name: String, test: suspend BehaviorSpecWhenContainerScope.() -> Unit) = addWhen(name, test, xdisabled = true)50 suspend fun xWhen(name: String, test: suspend BehaviorSpecWhenContainerScope.() -> Unit) = addWhen(name, test, xdisabled = true)51 private suspend fun addWhen(name: String, test: suspend BehaviorSpecWhenContainerScope.() -> Unit, xdisabled: Boolean) {52 registerContainer(TestName("When: ", name, true), disabled = xdisabled, null) {53 BehaviorSpecWhenContainerScope(this).test()54 }55 }56 fun Then(name: String) = TestWithConfigBuilder(57 TestName("Then: ", name, true),58 this@BehaviorSpecGivenContainerScope,59 xdisabled = false60 )61 fun then(name: String) = TestWithConfigBuilder(62 TestName("Then: ", name, true),63 this@BehaviorSpecGivenContainerScope,64 xdisabled = false65 )66 fun xthen(name: String) = TestWithConfigBuilder(67 TestName("Then: ", name, true),68 this@BehaviorSpecGivenContainerScope,69 xdisabled = true70 )71 fun xThen(name: String) = TestWithConfigBuilder(72 TestName("Then: ", name, true),73 this@BehaviorSpecGivenContainerScope,74 xdisabled = true75 )76 suspend fun Then(name: String, test: suspend TestScope.() -> Unit) = addThen(name, test, xdisabled = false)77 suspend fun then(name: String, test: suspend TestScope.() -> Unit) = addThen(name, test, xdisabled = false)78 suspend fun xthen(name: String, test: suspend TestScope.() -> Unit) = addThen(name, test, xdisabled = true)79 suspend fun xThen(name: String, test: suspend TestScope.() -> Unit) = addThen(name, test, xdisabled = true)80 private suspend fun addThen(name: String, test: suspend TestScope.() -> Unit, xdisabled: Boolean) {81 registerTest(TestName("Then: ", name, true), disabled = xdisabled, null, test)82 }83}...

Full Screen

Full Screen

then

Using AI Code Generation

copy

Full Screen

1 given("a string") {2 `when`("the string is uppercased") {3 val uppercased = str.uppercase()4 then("the result should be the same as the input") {5 }6 }7 }8 given("a string") {9 `when`("the string is uppercased") {10 val uppercased = str.uppercase()11 then("the result should be the same as the input") {12 }13 }14 }15 given("a string") {16 `when`("the string is uppercased") {17 val uppercased = str.uppercase()18 then("the result should be the same as the input") {19 }20 }21 }22 given("a string") {23 `when`("the string is uppercased") {24 val uppercased = str.uppercase()25 then("the result should be the same as the input") {26 }27 }28 }29}30BehaviorSpecTest.testBehaviorSpecStyle()

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in BehaviorSpecGivenContainerScope

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful