Best Kotest code snippet using io.kotest.matchers.string.matchers.beEmpty
BestellungRestTest.kt
Source:BestellungRestTest.kt
...23import com.acme.bestellung.rest.BestellungGetController.Companion.API_PATH24import com.acme.bestellung.rest.BestellungGetController.Companion.ID_PATTERN25import com.jayway.jsonpath.JsonPath26import io.kotest.assertions.assertSoftly27import io.kotest.matchers.collections.beEmpty28import io.kotest.matchers.collections.shouldContainExactly29import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder30import io.kotest.matchers.collections.shouldHaveSize31import io.kotest.matchers.shouldBe32import io.kotest.matchers.shouldNot33import io.kotest.matchers.shouldNotBe34import io.kotest.matchers.string.beBlank35import io.kotest.matchers.string.shouldMatch36import kotlinx.coroutines.ExperimentalCoroutinesApi37import kotlinx.coroutines.test.runTest38import org.junit.jupiter.api.DisplayName39import org.junit.jupiter.api.Nested40import org.junit.jupiter.api.Tag41import org.junit.jupiter.api.Test42import org.junit.jupiter.api.condition.EnabledForJreRange43import org.junit.jupiter.api.condition.JRE.JAVA_1744import org.junit.jupiter.api.condition.JRE.JAVA_1845import org.junit.jupiter.params.ParameterizedTest46import org.junit.jupiter.params.provider.CsvSource47import org.junit.jupiter.params.provider.ValueSource48import org.springframework.beans.factory.getBean49import org.springframework.boot.test.context.SpringBootTest50import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT51import org.springframework.boot.web.server.LocalServerPort52import org.springframework.context.ApplicationContext53import org.springframework.hateoas.MediaTypes.HAL_JSON54import org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer55import org.springframework.http.HttpStatus.CREATED56import org.springframework.http.HttpStatus.NOT_FOUND57import org.springframework.http.HttpStatus.OK58import org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY59import org.springframework.test.context.ActiveProfiles60import org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication61import org.springframework.web.reactive.function.client.WebClient62import org.springframework.web.reactive.function.client.awaitBodilessEntity63import org.springframework.web.reactive.function.client.awaitBody64import org.springframework.web.reactive.function.client.awaitEntity65import org.springframework.web.reactive.function.client.awaitExchange66import java.math.BigDecimal67import java.math.BigDecimal.TEN68@Tag("rest")69@DisplayName("REST-Schnittstelle fuer Bestellungen testen")70@SpringBootTest(webEnvironment = RANDOM_PORT)71@ActiveProfiles(DEV)72@EnabledForJreRange(min = JAVA_17, max = JAVA_18)73@Suppress("ClassName", "UseDataClass")74@ExperimentalCoroutinesApi75class BestellungRestTest(@LocalServerPort private val port: Int, ctx: ApplicationContext) {76 private val baseUrl = "$SCHEMA://$HOST:$port$API_PATH"77 private val client = WebClient.builder()78 .filter(basicAuthentication(USER_ADMIN, PASSWORD))79 .baseUrl(baseUrl)80 .build()81 init {82 ctx.getBean<BestellungGetController>() shouldNotBe null83 }84 // -------------------------------------------------------------------------85 // L E S E N86 // -------------------------------------------------------------------------87 @ExperimentalCoroutinesApi88 @Nested89 inner class Lesen {90 @ParameterizedTest91 @ValueSource(strings = [ID_VORHANDEN])92 fun `Suche mit vorhandener ID`(id: String) = runTest {93 // when94 val response = client.get()95 .uri(ID_PATH, id)96 .accept(HAL_JSON)97 .awaitExchange { response -> response.awaitEntity<String>() }98 // then99 assertSoftly(response) {100 statusCode shouldBe OK101 body shouldNotBe null102 val kundeNachname: String = JsonPath.read(body, "$.kundeNachname")103 kundeNachname shouldNot beBlank()104 kundeNachname shouldNotBe "Fallback"105 val linkDiscoverer = HalLinkDiscoverer()106 val selfLink = linkDiscoverer.findLinkWithRel("self", body ?: "").get().href107 selfLink shouldBe "$baseUrl/$id"108 }109 }110 @ParameterizedTest111 @ValueSource(strings = [ID_INVALID, ID_NICHT_VORHANDEN])112 fun `Suche mit syntaktisch ungueltiger oder nicht-vorhandener ID`() = runTest {113 // given114 val id = ID_INVALID115 // when116 val statusCode = client.get()117 .uri(ID_PATH, id)118 .accept(HAL_JSON)119 .awaitExchange { response -> response.statusCode() }120 // then121 statusCode shouldBe NOT_FOUND122 }123 @Test124 fun `Suche nach allen Bestellungen`() = runTest {125 // when126 val bestellungenModel = client.get()127 .accept(HAL_JSON)128 .retrieve()129 .awaitBody<BestellungenModel>()130 bestellungenModel._embedded.bestellungen shouldNot beEmpty()131 }132 @ParameterizedTest133 @ValueSource(strings = [KUNDE_ID])134 fun `Suche mit vorhandener Kunde-ID`(kundeId: String) = runTest {135 // when136 val bestellungenModel = client.get()137 .uri { builder ->138 builder139 .path(BESTELLUNG_PATH)140 .queryParam(KUNDE_ID_PARAM, kundeId)141 .build()142 }143 .accept(HAL_JSON)144 .retrieve()145 .awaitBody<BestellungenModel>()146 // then147 assertSoftly {148 val bestellungen = bestellungenModel._embedded.bestellungen149 bestellungen shouldNot beEmpty()150 bestellungen.onEach { bestellung ->151 bestellung.content?.kundeId.toString().lowercase() shouldBe kundeId.lowercase()152 }153 }154 }155 }156 // -------------------------------------------------------------------------157 // S C H R E I B E N158 // -------------------------------------------------------------------------159 @Nested160 inner class Schreiben {161 @ParameterizedTest162 @CsvSource("$KUNDE_ID, $ARTIKEL_ID")163 fun `Abspeichern einer neuen Bestellung`(kundeId: String, artikelId: String) = runTest {164 // given165 val bestellposition = Bestellposition(166 artikelId = ArtikelId.fromString(artikelId),167 anzahl = 1,168 einzelpreis = TEN,169 )170 val bestellpositionen = listOfNotNull(bestellposition)171 val neueBestellung = BestellungDTO(172 kundeId = KundeId.fromString(kundeId),173 bestellpositionen = bestellpositionen,174 )175 // when176 val response = client.post()177 .bodyValue(neueBestellung)178 .awaitExchange { response -> response.awaitBodilessEntity() }179 // then180 assertSoftly(response) {181 statusCode shouldBe CREATED182 val location = headers.location183 val id = location.toString().substringAfterLast('/')184 id shouldMatch ID_PATTERN185 }186 }187 @ParameterizedTest188 @ValueSource(strings = [KUNDE_ID])189 fun `Abspeichern einer leeren Bestellung`(kundeId: String) = runTest {190 // given191 val neueBestellung = Bestellung(192 kundeId = KundeId.fromString(kundeId),193 bestellpositionen = emptyList(),194 )195 val violationKeys = listOf("bestellung.bestellpositionen.notEmpty")196 // when197 val response = client.post()198 .bodyValue(neueBestellung)199 .awaitExchange { response -> response.awaitEntity<GenericBody.Values>() }200 // then201 assertSoftly(response) {202 statusCode shouldBe UNPROCESSABLE_ENTITY203 body shouldNotBe null204 checkNotNull(body) { "Der Rumpf darf nicht leer sein" }205 val violations = body!!.values206 val keys = violations.keys207 keys shouldNot beEmpty()208 keys shouldHaveSize 1209 keys shouldContainExactly violationKeys210 }211 }212 @ParameterizedTest213 @CsvSource("$KUNDE_ID, $ARTIKEL_ID")214 fun `Abspeichern einer ungueltigen Bestellung`(kundeId: String, artikelId: String) = runTest {215 // given216 val bestellposition = Bestellposition(217 artikelId = ArtikelId.fromString(artikelId),218 anzahl = 0,219 einzelpreis = BigDecimal("-1"),220 )221 val neueBestellung = Bestellung(222 kundeId = KundeId.fromString(kundeId),223 bestellpositionen = listOfNotNull(bestellposition),224 )225 val violationKeys = listOf("bestellposition.anzahl.min", "bestellposition.einzelpreis.min")226 // when227 val response = client.post()228 .bodyValue(neueBestellung)229 .awaitExchange { response -> response.awaitEntity<GenericBody.Values>() }230 // then231 assertSoftly(response) {232 statusCode shouldBe UNPROCESSABLE_ENTITY233 body shouldNotBe null234 checkNotNull(body) { "Der Rumpf darf nicht leer sein" }235 val violations = body!!.values236 val keys = violations.keys237 keys shouldNot beEmpty()238 keys shouldHaveSize 2239 keys shouldContainExactlyInAnyOrder violationKeys240 }241 }242 }243 private companion object {244 const val SCHEMA = "http"245 const val HOST: String = "localhost"246 const val BESTELLUNG_PATH = "/"247 const val ID_PATH = "/{id}"248 const val KUNDE_ID_PARAM = "kundeId"249 const val USER_ADMIN = "admin"250 const val PASSWORD = "p"251 const val ID_VORHANDEN = "10000000-0000-0000-0000-000000000001"...
KotlinTest.kt
Source:KotlinTest.kt
...3import io.kotest.matchers.collections.sorted4import io.kotest.matchers.should5import io.kotest.matchers.shouldBe6import io.kotest.matchers.string.*7import io.kotest.matchers.collections.beEmpty8import io.kotest.matchers.maps.contain9import io.kotest.matchers.maps.haveKey10import io.kotest.matchers.maps.haveValue11class StringSpecTest : StringSpec() {12 // StringSpec를 ìì ë°ì¼ë©°, ë³´íµ init ë¸ë ë´ìì í
ì¤í¸ ì½ë를 ìì±íë¤.13 // init ë¸ë¡ ë´ë¶ì 문ìì´ì í
ì¤í¸ë¥¼ ì¤ëª
íë ë¶ë¶ì´ë©°, ë¸ë ë´ë¶ì ì½ëê° ì¤ì í
ì¤í¸ê° ì§íëë ë¶ë¶ì´ë¤.14 init {15 "문ìì´.lengthê° ë¬¸ìì´ì 길ì´ë¥¼ 리í´í´ì¼ í©ëë¤." {16 "kotlin test".length shouldBe 1117 }18 }19}20class FunSpecTest : FunSpec({21 // FunSpecë í¨ì ííë¡ í
ì¤í¸ ì½ë를 ìì±í ì ìëë¡ ëëë¤.22 // í
ì¤í¸ í¨ìì ë§¤ê° ë³ìë ë¨ì í
ì¤í¸ ì¤ëª
ì´ë©°, í
ì¤í¸ í¨ì ë´ë¶ì ì½ëê° ì¤ì í
ì¤í¸ê° ì§íëë ë¶ë¶ì´ë¤.23 test("문ìì´ì 길ì´ë¥¼ 리í´í´ì¼ í©ëë¤.") {24 "kotlin".length shouldBe 625 "".length shouldBe 026 }27})28class ShouldSpecTest : ShouldSpec({29 // ShouldSpecë FunSpecê³¼ ì ì¬íë¤. ë¤ë§, test ëì should í¤ìë를 ì¬ì©íë¤ë ì°¨ì´ì ì´ ìë¤.30 // ìë should ì ë§¤ê° ë³ìë ë¨ì ì¤ëª
ì´ê³ , í
ì¤í¸ë ìì ë¸ë ë´ë¶ìì ëìíë¤.31 should("문ìì´ì 길ì´ë¥¼ 리í´í´ì¼ í©ëë¤.") {32 "kotlin".length shouldBe 633 "".length shouldBe 034 }35})36class WordSpecTest : WordSpec({37 // String.length ë¶ë¶ì context stringì´ë¤. ì´ë í íê²½ìì í
ì¤í¸ë¥¼ ì§íí ê²ì¸ì§ë¥¼ ë§í´ 주ë ê²ì´ë¤.38 // ìë íê¸ì ìì ì¤ëª
ë¶ë¶ì´ë©°, ì½ë ë¸ë ë´ë¶ìì ì¤ì í
ì¤í¸ê° ëìíë¤.39 "String.length" should {40 "문ìì´ì 길ì´ë¥¼ 리í´í´ì¼ í©ëë¤." {41 "kotlin".length shouldBe 642 "".length shouldBe 043 }44 }45})46class BehaviorSpecTest : BehaviorSpec({47 // BehaviorSpecë BDD (Behaviour Driven Development)48 given("ì ê°ë½") {49 `when`("ì¡ëë¤.") {50 then("ììì 먹ëë¤.") {51 println("ì ê°ë½ì ì¡ê³ , ììì 먹ëë¤.")52 }53 }54 `when`("ëì§ë¤.") {55 then("ì¬ëì´ ë§ëë¤.") {56 println("ì ê°ë½ì ëì§ë©´, ì¬ëì´ ë§ëë¤.")57 }58 }59 }60})61class AnnotationSpecTest : AnnotationSpec() {62 // AnnotationSpecë JUnit ì¤íì¼(PersonTest íì¼ ì°¸ê³ )ë¡ í
ì¤í¸ ì½ë를 ìì±í ì ìë¤.63 @BeforeEach64 fun beforeTest() {65 println("Before Test, Setting")66 }67 @Test68 fun test1() {69 "test".length shouldBe 470 }71 @Test72 fun test2() {73 "test2".length shouldBe 574 }75}76class MatcherTest : StringSpec() {77 init {78 // shouldBeë ëì¼í¨ì ì²´í¬íë Matcher ì´ë¤.79 "hello World" shouldBe haveLength(11) // lengthê° ë§¤ê°ë³ìì ì ë¬ë ê°ì´ì´ì¼ í¨ì ì²´í¬íë¤.80 "hello" should include("ll") // 매ê°ë³ì ê°ì´ í¬í¨ëì´ ìëì§ íì¸íë¤.81 "hello" should endWith("lo") // 매ê°ë³ìì ëì´ í¬í¨ëëì§ íì¸íë¤.82 "hello" should match("he...") // 매ê°ë³ìê° ë§¤ì¹ëëì§ ì²´í¬íë¤.83 "hello".shouldBeLowerCase() // ì문ìë¡ ìì±ë ê²ì´ ë§ëì§ ì²´í¬íë¤.84 val list = emptyList<String>()85 val list2 = listOf("aaa", "bbb", "ccc")86 val map = mapOf<String, String>(Pair("aa", "11"))87 list should beEmpty() // ììê° ë¹ìëì§ íì¸íë¤.88 list2 shouldBe sorted<String>() // í´ë¹ ìë£íì´ ì ë ¬ëì´ ìëì§ íì¸íë¤.89 map should contain("aa", "11") // í´ë¹ ììê° í¬í¨ëì´ ìëì§ íì¸íë¤.90 map should haveKey("aa") // í´ë¹ í¤ ê°ì´ í¬í¨ëì´ ìëì§ íì¸íë¤.91 map should haveValue("11") // í´ë¹ value ê°ì´ í¬í¨ëì´ ìëì§ íì¸íë¤.92 }93}...
UnitsTest.kt
Source:UnitsTest.kt
...7import io.kotest.matchers.ints.shouldBeGreaterThan8import io.kotest.matchers.ints.shouldBeGreaterThanOrEqual9import io.kotest.matchers.should10import io.kotest.matchers.shouldNot11import io.kotest.matchers.string.beEmpty12class UnitsTest : WordSpec() {13 init {14 "All ${values().size} units" should {15 values()16 .forEach { unitBlueprint ->17 "be valid and instantiate a unit correctly: ${unitBlueprint.name}" {18 shouldNotThrowAny {19 unitBlueprint.new()20 }21 }22 "have a name: ${unitBlueprint.name}" {23 unitBlueprint.name shouldNot beEmpty()24 unitBlueprint.new().name shouldNot beEmpty()25 }26 "have a personnel count > minimumPersonnel: ${unitBlueprint.name}" {27 unitBlueprint.personnel shouldBeGreaterThan 028 unitBlueprint.personnel shouldBeGreaterThanOrEqual unitBlueprint.personnelMinimum29 }30 }31 }32 "Adding two unit blueprints" should {33 "result in a list containing both" {34 Radioman + Grenadier shouldContainExactly listOf(Radioman, Grenadier)35 }36 }37 "Adding a unit blueprint to a list of blueprints" should {38 "result in a list containing all three" {39 val blueprints = listOf(ScoutCar, ScoutPlane)40 blueprints + Officer shouldContainExactly listOf(ScoutCar, ScoutPlane, Officer)41 Medic + blueprints shouldContainExactly listOf(Medic, ScoutCar, ScoutPlane)42 }43 }44 "Multiplying a unit blueprint" should {45 "result in a list with x entries" {46 Rifleman * 3 shouldContainExactly listOf(Rifleman, Rifleman, Rifleman)47 }48 "result in an empty list with factor 0" {49 MainBattleTank * 0 should io.kotest.matchers.collections.beEmpty()50 }51 "fail with a negative factor" {52 shouldThrowAny {53 APC * -354 }55 }56 }57 }58}...
IdTests.kt
Source:IdTests.kt
1package dev.fritz2.elemento2import io.kotest.core.spec.style.FunSpec3import io.kotest.matchers.shouldBe4import io.kotest.matchers.shouldNotBe5import io.kotest.matchers.string.beEmpty6import io.kotest.matchers.string.shouldNotContain7import io.kotest.matchers.string.shouldNotEndWith8import io.kotest.matchers.string.shouldNotStartWith9import io.kotest.property.Arb10import io.kotest.property.arbitrary.string11import io.kotest.property.checkAll12class IdTests : FunSpec({13 test("simple") {14 Id.build("foo") shouldBe "foo"15 }16 test("additional ids") {17 Id.build("foo", "bar", "1-2", "3") shouldBe "foo-bar-1-2-3"18 }19 test("empty and null") {20 Id.build("") shouldBe beEmpty()21 Id.build("-") shouldBe beEmpty()22 Id.build("!@#$%^") shouldBe beEmpty()23 Id.build("foo", "", "", "bar", "") shouldBe "foo-bar"24 }25 test("complex") {26 Id.build("lorem-ipsum") shouldBe "lorem-ipsum"27 Id.build("Lorem Ipsum") shouldBe "lorem-ipsum"28 Id.build("Lorem", "Ipsum") shouldBe "lorem-ipsum"29 Id.build(" Lorem ", " Ipsum ") shouldBe "lorem-ipsum"30 Id.build("l0rem ip5um") shouldBe "l0rem-ip5um"31 Id.build("l0rem", "ip5um") shouldBe "l0rem-ip5um"32 Id.build(" l0rem ", " ip5um ") shouldBe "l0rem-ip5um"33 Id.build("""lorem §±!@#$%^&*()=_+[]{};'\:"|,./<>?`~ ipsum""") shouldBe "lorem-ipsum"34 Id.build("lorem", """§±!@#$%^&*()=_+[]{};'\:"|,./<>?`~""", "ipsum") shouldBe "lorem-ipsum"35 }36 test("similar") {...
MessageTests.kt
Source:MessageTests.kt
...5import dev.discordkt.models.user.UserFlag6import java.time.OffsetDateTime7import java.time.ZoneOffset8import io.kotest.core.spec.style.StringSpec9import io.kotest.matchers.collections.beEmpty10import io.kotest.matchers.collections.shouldContainExactly11import io.kotest.matchers.should12import io.kotest.matchers.shouldBe13class MessageTests : StringSpec({14 "Normal Message" {15 """16 {17 "id": "761996835337928715",18 "type": 0,19 "content": "This is a message",20 "channel_id": "761287705354567680",21 "author": {22 "id": "310702108997320705",23 "username": "romangraef89",24 "avatar": "f1fb2bd7862ba7153b98c94bbdb7e750",25 "discriminator": "0998",26 "public_flags": 13120027 },28 "attachments": [],29 "embeds": [],30 "mentions": [],31 "mention_roles": [],32 "pinned": false,33 "mention_everyone": false,34 "tts": false,35 "timestamp": "2020-10-03T17:03:22.761000+00:00",36 "edited_timestamp": null,37 "flags": 038 }39 """.trimIndent().deserializes<Message> {40 it.longId shouldBe 761996835337928715L41 it.type shouldBe MessageType.DEFAULT42 it.content shouldBe "This is a message"43 it.channelId.longId shouldBe 761287705354567680L44 it.author.longId shouldBe 310702108997320705L45 it.author.username shouldBe "romangraef89"46 it.author.avatarHash shouldBe "f1fb2bd7862ba7153b98c94bbdb7e750"47 it.author.discriminator shouldBe "0998"48 it.author.publicFlags shouldContainExactly setOf(UserFlag.HOUSE_BRILLIANCE, UserFlag.VERIFIED_BOT_DEVELOPER)49 it.attachments should beEmpty()50 it.embeds should beEmpty()51 it.mentions should beEmpty()52 it.pinned shouldBe false53 it.mentionEveryone shouldBe false54 it.tts shouldBe false55 it.timestamp shouldBe OffsetDateTime.of(56 2020, 10, 3,57 17, 3, 22, 761000000, ZoneOffset.ofHours(0)58 )59 it.editedTimestamp shouldBe null60 it.flags!! should beEmpty()61 }62 }63})...
FormatFileTest.kt
Source:FormatFileTest.kt
2import com.github.difflib.DiffUtils3import io.kotest.core.spec.style.WordSpec4import io.kotest.core.spec.tempfile5import io.kotest.matchers.and6import io.kotest.matchers.collections.beEmpty7import io.kotest.matchers.nulls.beNull8import io.kotest.matchers.paths.aFile9import io.kotest.matchers.paths.beReadable10import io.kotest.matchers.paths.exist11import io.kotest.matchers.should12import io.kotest.matchers.shouldNot13import java.io.File14import java.nio.file.Files15import java.nio.file.Path16import java.nio.file.Paths17import java.nio.file.StandardCopyOption18class FormatFileTest : WordSpec() {19 companion object {20 val LINE_SEPARATOR = System.getProperty("line.separator") ?: "\n";21 }22 private lateinit var actual: File23 private fun resourcePath(name: String): Path {24 val path = this.javaClass.getResource(name)?.let {25 Paths.get(it.file)26 }27 path shouldNot beNull()28 path!! should (exist() and aFile() and beReadable())29 return path.normalize()30 }31 init {32 beforeTest {33 actual = tempfile("format-test")34 }35 "eclipselink result file" should {36 "be formatted" {37 val source = resourcePath("/eclipselink-normal-result.txt")38 val expected = resourcePath("/eclipselink-format-result.txt")39 val actualPath = actual.toPath()40 Files.copy(source, actualPath, StandardCopyOption.REPLACE_EXISTING)41 formatFile(actualPath, true, LINE_SEPARATOR)42 val diff = DiffUtils.diff(Files.readAllLines(expected), Files.readAllLines(actualPath))43 diff.deltas should beEmpty()44 }45 }46 "hibernate result file" should {47 "be formatted" {48 val source = resourcePath("/hibernate-normal-result.txt")49 val expected = resourcePath("/hibernate-format-result.txt")50 val actualPath = actual.toPath()51 Files.copy(source, actualPath, StandardCopyOption.REPLACE_EXISTING)52 formatFile(actualPath, true, LINE_SEPARATOR)53 val diff = DiffUtils.diff(Files.readAllLines(expected), Files.readAllLines(actualPath))54 diff.deltas should beEmpty()55 }56 }57 }58}...
QueryTest.kt
Source:QueryTest.kt
1package com.nuglif.kuri2import io.kotest.assertions.assertSoftly3import io.kotest.matchers.maps.beEmpty4import io.kotest.matchers.maps.haveKey5import io.kotest.matchers.maps.haveSize6import io.kotest.matchers.maps.shouldContain7import io.kotest.matchers.should8import io.kotest.matchers.shouldBe9import io.kotest.matchers.string.shouldBeEmpty10import kotlin.test.Test11class ToParametersTest {12 @Test13 fun givenEmptyQuery_thenReturnEmptyMap() {14 "".asQuery().toParameters() should beEmpty()15 }16 @Test17 fun givenQueryWithoutVariableSeparator_thenReturnSingleElement() {18 "someVariable=someValue".asQuery().toParameters() should haveSize(1)19 }20 @Test21 fun givenQueryWithoutValueSeparator_thenReturnElementMappedToEmptyString() {22 val result = "someVariable&someOtherValue".asQuery().toParameters()23 assertSoftly {24 result should haveSize(2)25 result shouldContain ("someVariable" to "")26 result shouldContain ("someOtherValue" to "")27 }28 }...
ToudouSteps.kt
Source:ToudouSteps.kt
...5import io.cucumber.java8.En6import io.kotest.matchers.collections.shouldBeEmpty7import io.kotest.matchers.shouldBe8import io.kotest.matchers.shouldNot9import io.kotest.matchers.string.beEmpty10class ToudouSteps : En {11 private lateinit var toudous: Toudous12 private lateinit var toudouList: List<Toudou>13 private lateinit var toudou: Toudou14 init {15 Given("Empty/A toudous") {16 toudous = Toudous()17 }18 When("I list all toudous") {19 toudouList = toudous.all20 }21 When("I add a toudou with label {string}") { label: String ->22 toudou = toudous.add(Label(label))23 }24 Then("my toudous are empty") {25 toudouList.shouldBeEmpty()26 }27 Then("a toudou should be created") {}28 Then("the toudou should have an Id") {29 toudou.toudouId.toString() shouldNot beEmpty()30 }31 Then("the toudou should have a label {string}") { label: String ->32 toudou.label.value shouldBe label33 }34 }35}...
beEmpty
Using AI Code Generation
1import io.kotest.matchers.string.shouldBeEmpty2import io.kotest.matchers.string.shouldNotBeEmpty3import io.kotest.matchers.string.shouldContain4import io.kotest.matchers.string.shouldNotContain5import io.kotest.matchers.string.shouldStartWith6import io.kotest.matchers.string.shouldEndWith7import io.kotest.matchers.string.shouldMatch8import io.kotest.matchers.string.shouldNotMatch9import io.kotest.matchers.string.shouldContainAll10import io.kotest.matchers.string.shouldContainAny11import io.kotest.matchers.string.shouldContainNone12import io.kotest.matchers.string.shouldContainOnlyDigits13import io.kotest.matchers.string.shouldContainOnlyLetters14import io.kotest.matchers.string.shouldContainOnlyLowerCase15import io.kotest.matchers.string.shouldContainOnlyUpperCase16import io.kotest.matchers.string.should
beEmpty
Using AI Code Generation
1assertThat("".isEmpty()).isTrue()2assertThat(listOf<Int>()).isEmpty()3assertThat(mapOf<Int, String>()).isEmpty()4assertThat(listOf<Int>()).isEmpty()5assertThat(Optional.of(1)).isEmpty()6assertThat(Optional.empty<Int>()).isEmpty()7assertThat(Optional.ofNullable(null)).isEmpty()8assertThat(Optional.ofNullable(1)).isEmpty()9assertThat(Optional.ofNullable(null)).isEmpty()10assertThat(Optional.ofNullable(1)).isEmpty()11assertThat(Optional.ofNullable(null)).isEmpty()12assertThat(Optional.ofNullable(1)).isEmpty()13assertThat(Optional.ofNullable(null)).isEmpty()14assertThat(Optional.ofNullable(1)).isEmpty()15assertThat(Optional.ofNullable(null)).isEmpty()16assertThat(Optional.ofNullable(1)).isEmpty()17assertThat(Optional.ofNullable(null)).isEmpty()18assertThat(Optional.ofNullable(1)).isEmpty()
beEmpty
Using AI Code Generation
1"Hello".shouldBeEmpty()2listOf(1, 2, 3).shouldHaveSize(3)3"Hello".shouldHaveLength(5)4null.shouldBeNull()5true.shouldBeTrue()6false.shouldBeFalse()7obj.shouldBeInstanceOf<String>()8obj1.shouldBeSameInstanceAs(obj2)9val list = listOf(1, 2, 3)10list.shouldBeOneOf(listOf(1, 2, 3), listOf(1, 2, 4))11listOf(1, 2, 3).shouldBeIn(listOf(1, 2, 3))12listOf(1, 2, 3).shouldBeSorted()13listOf(1, 2, 3).shouldBeSortedWith(compareBy { it })14listOf(1, 2, 3).shouldBeSortedBy { it }15listOf(3, 2, 1).shouldBeSortedDescending()16listOf(3,
beEmpty
Using AI Code Generation
1 import io.kotest.matchers.string.shouldBeEmpty2 import org.junit.jupiter.api.Test3 class StringTest {4 fun `should be empty`() {5 "".shouldBeEmpty()6 }7 }
beEmpty
Using AI Code Generation
1assertThat(“”)2.toBeEmpty()3assertThat(“ “)4.toBeEmpty()5assertThat(“Hello”)6.toBeEmpty()7assertThat(“”)8.toBeBlank()9assertThat(“ “)10.toBeBlank()11assertThat(“Hello”)12.toBeBlank()13assertThat(“Hello”)14.toBeBlank()15assertThat(“”)16.toHaveLength(0)17assertThat(“
beEmpty
Using AI Code Generation
1 "should be empty" {2 "".shouldBeEmpty()3 }4}5class StringSpecExample : StringSpec() {6 init {7 "should contain substring" {8 "hello world" should contain("world")9 }10 }11}12@Tags("tag1", "tag2")13class StringSpecExample : StringSpec() {14 init {15 "should contain substring" {16 "hello world" should contain("world")17 }18 }19}20includeTags("tag1")
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!