How to use case class of io.kotest.matchers.string package

Best Kotest code snippet using io.kotest.matchers.string.case

FailingKotestAsserts.kt

Source:FailingKotestAsserts.kt Github

copy

Full Screen

1package testing.failing2import arrow.core.*3import io.kotest.assertions.arrow.either.shouldBeLeft4import io.kotest.assertions.arrow.either.shouldBeRight5import io.kotest.assertions.arrow.nel.shouldContain6import io.kotest.assertions.arrow.nel.shouldContainNull7import io.kotest.assertions.arrow.option.shouldBeNone8import io.kotest.assertions.arrow.option.shouldBeSome9import io.kotest.assertions.arrow.validation.shouldBeInvalid10import io.kotest.assertions.arrow.validation.shouldBeValid11import io.kotest.assertions.asClue12import io.kotest.assertions.assertSoftly13import io.kotest.assertions.json.*14import io.kotest.assertions.throwables.shouldThrowAny15import io.kotest.assertions.throwables.shouldThrowExactly16import io.kotest.assertions.withClue17import io.kotest.matchers.Matcher18import io.kotest.matchers.MatcherResult19import io.kotest.matchers.booleans.shouldBeFalse20import io.kotest.matchers.booleans.shouldBeTrue21import io.kotest.matchers.collections.shouldBeEmpty22import io.kotest.matchers.collections.shouldBeOneOf23import io.kotest.matchers.collections.shouldBeSameSizeAs24import io.kotest.matchers.collections.shouldBeSorted25import io.kotest.matchers.collections.shouldContain26import io.kotest.matchers.date.shouldBeAfter27import io.kotest.matchers.ints.shouldBeEven28import io.kotest.matchers.ints.shouldBeGreaterThan29import io.kotest.matchers.ints.shouldBeGreaterThanOrEqual30import io.kotest.matchers.ints.shouldBeLessThan31import io.kotest.matchers.ints.shouldBeLessThanOrEqual32import io.kotest.matchers.ints.shouldBeZero33import io.kotest.matchers.maps.shouldBeEmpty34import io.kotest.matchers.maps.shouldContain35import io.kotest.matchers.maps.shouldContainKey36import io.kotest.matchers.maps.shouldContainValue37import io.kotest.matchers.nulls.shouldBeNull38import io.kotest.matchers.should39import io.kotest.matchers.shouldBe40import io.kotest.matchers.shouldNot41import io.kotest.matchers.string.shouldBeBlank42import io.kotest.matchers.string.shouldBeEmpty43import io.kotest.matchers.string.shouldBeUpperCase44import io.kotest.matchers.string.shouldContain45import io.kotest.matchers.string.shouldNotBeBlank46import java.time.LocalDate47import org.junit.jupiter.api.Test48/**49 * Kotest assertions50 *51 * - [Kotest Assertions Documentation](https://kotest.io/assertions/)52 * - [Github](https://github.com/kotest/kotest/)53 */54class FailingKotestAsserts {55 @Test56 fun `General assertions`() {57 assertSoftly {58 "text" shouldBe "txet"59 "hi".shouldBeBlank()60 " ".shouldNotBeBlank()61 "hi".shouldBeEmpty()62 "hi".shouldBeUpperCase()63 "hello".shouldContain("hi")64 false.shouldBeTrue()65 true.shouldBeFalse()66 "not null".shouldBeNull()67 10 shouldBeLessThan 1068 10 shouldBeLessThanOrEqual 969 11 shouldBeGreaterThan 1170 11 shouldBeGreaterThanOrEqual 1271 9.shouldBeEven()72 1.shouldBeZero()73 }74 }75 @Test76 fun `Exception assertions`() {77 assertSoftly {78 shouldThrowExactly<IllegalArgumentException> {79 angryFunction()80 }81 shouldThrowAny {82 "I'm not throwing anything"83 }84 }85 }86 @Test87 fun `Collection assertions`() {88 assertSoftly {89 listOf(1, 2, 3).shouldBeEmpty()90 listOf(1, 2, 3) shouldContain 491 listOf(1, 3, 2).shouldBeSorted()92 listOf(1, 2, 3, 4) shouldBeSameSizeAs listOf(4, 5, 6)93 1 shouldBeOneOf listOf(2, 3)94 mapOf(1 to "one", 2 to "two", 3 to "three").shouldBeEmpty()95 mapOf(1 to "one", 2 to "two", 3 to "three") shouldContainKey 496 mapOf(1 to "one", 2 to "two", 3 to "three") shouldContainValue "five"97 mapOf(1 to "one", 2 to "two", 3 to "three") shouldContain (6 to "six")98 }99 }100 @Test101 fun `Arrow assertions`() {102 assertSoftly {103 val optionNone = none<String>()104 val optionSome = Some("I am something").toOption()105 optionSome.shouldBeNone()106 optionNone.shouldBeSome()107 val rightEither = Either.Right(1)108 val leftEither = Either.Left("ERROR!!")109 leftEither.shouldBeRight()110 leftEither shouldBeRight 1111 rightEither.shouldBeLeft()112 rightEither shouldBeLeft "ERROR!!"113 val nonEmptyList = NonEmptyList.of(1, 2, 3, 4, 5)114 nonEmptyList shouldContain 6115 nonEmptyList.shouldContainNull()116 val valid = Validated.valid()117 val invalid = Validated.invalid()118 invalid.shouldBeValid()119 valid.shouldBeInvalid()120 }121 }122 @Test123 fun `Json assertions`() {124 val jsonString = "{\"test\": \"property\", \"isTest\": true }"125 assertSoftly {126 jsonString shouldMatchJson "{\"test\": \"otherProperty\"}"127 jsonString shouldContainJsonKey "$.anotherTest"128 jsonString shouldNotContainJsonKey "$.test"129 jsonString.shouldContainJsonKeyValue("$.isTest", false)130 }131 }132 @Test133 fun `Custom assertions`() {134 assertSoftly {135 val sentMail = Mail(136 dateCreated = LocalDate.of(2020, 10, 27),137 sent = true, message = "May you have an amazing day"138 )139 val unsentMail = Mail(140 dateCreated = LocalDate.of(2020, 10, 27),141 sent = false, message = "May you have an amazing day"142 )143 // This is possible144 unsentMail.sent should beSent()145 sentMail.sent shouldNot beSent()146 // This is recommended147 unsentMail.shouldBeSent()148 sentMail.shouldNotBeSent()149 }150 }151 @Test152 fun `withClue usage`() {153 val mail = Mail(154 dateCreated = LocalDate.of(2020, 10, 27),155 sent = false, message = "May you have an amazing day"156 )157 withClue("sent field should be true") {158 mail.sent shouldBe true159 }160 mail.asClue {161 it.dateCreated shouldBeAfter LocalDate.of(2020, 10, 26)162 it.sent shouldBe true163 }164 }165 @Test166 fun `asClue usage`() {167 val mail = Mail(168 dateCreated = LocalDate.of(2020, 10, 27),169 sent = false, message = "May you have an amazing day"170 )171 mail.asClue {172 it.dateCreated shouldBeAfter LocalDate.of(2020, 10, 26)173 it.sent shouldBe true174 }175 }176 fun beSent() = object : Matcher<Boolean> {177 override fun test(value: Boolean) = MatcherResult(value, "Mail.sent should be true", "Mail.sent should be false")178 }179 fun Mail.shouldBeSent() = this.sent should beSent()180 fun Mail.shouldNotBeSent() = this.sent shouldNot beSent()181}182data class Mail(val dateCreated: LocalDate, val sent: Boolean, val message: String)183fun angryFunction() {184 throw IllegalStateException("How dare you!")185}...

Full Screen

Full Screen

NoteViewModelTest.kt

Source:NoteViewModelTest.kt Github

copy

Full Screen

1package com.noto.app.viewModel2import com.noto.app.util.appModule3import com.noto.app.domain.model.Library4import com.noto.app.domain.model.Note5import com.noto.app.domain.repository.LibraryRepository6import com.noto.app.domain.repository.NoteRepository7import com.noto.app.fakeLocalDataSourceModule8import com.noto.app.note.NoteViewModel9import com.noto.app.testRepositoryModule10import io.kotest.core.spec.style.StringSpec11import io.kotest.matchers.booleans.shouldBeFalse12import io.kotest.matchers.booleans.shouldBeTrue13import io.kotest.matchers.collections.shouldBeEmpty14import io.kotest.matchers.collections.shouldHaveSize15import io.kotest.matchers.collections.shouldNotBeEmpty16import io.kotest.matchers.longs.shouldBeExactly17import io.kotest.matchers.nulls.shouldBeNull18import io.kotest.matchers.nulls.shouldNotBeNull19import io.kotest.matchers.shouldBe20import io.kotest.matchers.string.shouldBeBlank21import io.kotest.matchers.string.shouldBeEqualIgnoringCase22import kotlinx.coroutines.flow.first23import kotlinx.coroutines.flow.map24import kotlinx.datetime.Clock25import org.koin.core.context.startKoin26import org.koin.core.context.stopKoin27import org.koin.core.parameter.parametersOf28import org.koin.test.KoinTest29import org.koin.test.get30class NoteViewModelTest : StringSpec(), KoinTest {31 private lateinit var viewModel: NoteViewModel32 private lateinit var libraryRepository: LibraryRepository33 private lateinit var noteRepository: NoteRepository34 init {35 beforeEach {36 startKoin {37 modules(appModule, testRepositoryModule, fakeLocalDataSourceModule)38 }39 libraryRepository = get()40 noteRepository = get()41 libraryRepository.createLibrary(Library(id = 1, title = "Work", position = 0))42 libraryRepository.createLibrary(Library(id = 2, title = "Home", position = 0))43 noteRepository.createNote(Note(id = 1, libraryId = 1, title = "Title", body = "Body", position = 0))44 viewModel = get { parametersOf(1L, 1L) }45 }46 afterEach {47 stopKoin()48 }49 "get library should return library with matching id" {50 val library = viewModel.state51 .map { it.library }52 .first()53 library.id shouldBeExactly 154 library.title shouldBeEqualIgnoringCase "Work"55 }56 "get note should return a default note when note id is 0" {57 viewModel = get { parametersOf(1L, 0L) }58 val note = viewModel.state59 .map { it.note }60 .first()61 note.id shouldBeExactly 0L62 note.title.shouldBeBlank()63 }64 "get note should return a note with matching id" {65 val note = viewModel.state66 .map { it.note }67 .first()68 note.id shouldBeExactly 1L69 note.title shouldBeEqualIgnoringCase "Title"70 }71 "update note should update the note with matching id" {72 viewModel.createOrUpdateNote("Title 2", "Body 2")73 val note = noteRepository.getNoteById(noteId = 1)74 .first()75 note.id shouldBeExactly 1L76 note.title shouldBeEqualIgnoringCase "Title 2"77 note.body shouldBeEqualIgnoringCase "Body 2"78 }79 "delete note should remove note with matching id" {80 viewModel.deleteNote()81 noteRepository.getNotesByLibraryId(libraryId = 1)82 .first()83 .shouldBeEmpty()84 }85 "toggle note is archived should set note archived property to true" {86 noteRepository.getNoteById(noteId = 1)87 .first()88 .isArchived89 .shouldBeFalse()90 viewModel.toggleNoteIsArchived()91 noteRepository.getNoteById(noteId = 1)92 .first()93 .isArchived94 .shouldBeTrue()95 }96 "toggle note is starred should set note starred property to true" {97 noteRepository.getNoteById(noteId = 1)98 .first()99 .isPinned100 .shouldBeFalse()101 viewModel.toggleNoteIsPinned()102 noteRepository.getNoteById(noteId = 1)103 .first()104 .isPinned105 .shouldBeTrue()106 }107 "set note reminder should set note reminder with provided value" {108 val now = Clock.System.now()109 noteRepository.getNoteById(noteId = 1)110 .first()111 .reminderDate112 .shouldBeNull()113 viewModel.setNoteReminder(now)114 noteRepository.getNoteById(noteId = 1)115 .first()116 .reminderDate117 .shouldNotBeNull()118 .shouldBe(now)119 }120 "duplicate note should create new note with same data" {121 noteRepository.getNotesByLibraryId(libraryId = 1L)122 .first()123 .shouldNotBeEmpty()124 .shouldHaveSize(1)125 viewModel.duplicateNote()126 noteRepository.getNotesByLibraryId(libraryId = 1L)127 .first()128 .shouldNotBeEmpty()129 .shouldHaveSize(2)130 .onEach {131 it.title shouldBeEqualIgnoringCase "Title"132 it.body shouldBeEqualIgnoringCase "Body"133 }134 }135 "copy note should create a new note with a different library id" {136 noteRepository.getNotesByLibraryId(libraryId = 2)137 .first()138 .shouldBeEmpty()139 viewModel.copyNote(libraryId = 2)140 noteRepository.getNotesByLibraryId(libraryId = 2)141 .first()142 .shouldNotBeEmpty()143 .shouldHaveSize(1)144 }145 "move note should move current note to a different library" {146 noteRepository.getNotesByLibraryId(libraryId = 1)147 .first()148 .shouldNotBeEmpty()149 .shouldHaveSize(1)150 noteRepository.getNotesByLibraryId(libraryId = 2)151 .first()152 .shouldBeEmpty()153 viewModel.moveNote(libraryId = 2)154 noteRepository.getNotesByLibraryId(libraryId = 1)155 .first()156 .shouldBeEmpty()157 noteRepository.getNotesByLibraryId(libraryId = 2)158 .first()159 .shouldNotBeEmpty()160 .shouldHaveSize(1)161 }162 }163}...

Full Screen

Full Screen

KotestAsserts.kt

Source:KotestAsserts.kt Github

copy

Full Screen

1package testing.asserts2import arrow.core.*3import io.kotest.assertions.arrow.either.shouldBeLeft4import io.kotest.assertions.arrow.either.shouldBeRight5import io.kotest.assertions.arrow.nel.shouldContain6import io.kotest.assertions.arrow.nel.shouldContainNull7import io.kotest.assertions.arrow.option.shouldBeNone8import io.kotest.assertions.arrow.option.shouldBeSome9import io.kotest.assertions.arrow.validation.shouldBeInvalid10import io.kotest.assertions.arrow.validation.shouldBeValid11import io.kotest.assertions.asClue12import io.kotest.assertions.json.*13import io.kotest.assertions.throwables.shouldThrowAny14import io.kotest.assertions.throwables.shouldThrowExactly15import io.kotest.assertions.withClue16import io.kotest.matchers.Matcher17import io.kotest.matchers.MatcherResult18import io.kotest.matchers.booleans.shouldBeFalse19import io.kotest.matchers.booleans.shouldBeTrue20import io.kotest.matchers.collections.shouldBeEmpty21import io.kotest.matchers.collections.shouldBeOneOf22import io.kotest.matchers.collections.shouldBeSameSizeAs23import io.kotest.matchers.collections.shouldBeSorted24import io.kotest.matchers.collections.shouldContain25import io.kotest.matchers.date.shouldBeAfter26import io.kotest.matchers.ints.shouldBeEven27import io.kotest.matchers.ints.shouldBeGreaterThan28import io.kotest.matchers.ints.shouldBeGreaterThanOrEqual29import io.kotest.matchers.ints.shouldBeLessThan30import io.kotest.matchers.ints.shouldBeLessThanOrEqual31import io.kotest.matchers.ints.shouldBeZero32import io.kotest.matchers.maps.shouldBeEmpty33import io.kotest.matchers.maps.shouldContain34import io.kotest.matchers.maps.shouldContainKey35import io.kotest.matchers.maps.shouldContainValue36import io.kotest.matchers.nulls.shouldBeNull37import io.kotest.matchers.should38import io.kotest.matchers.shouldBe39import io.kotest.matchers.shouldNot40import io.kotest.matchers.string.shouldBeBlank41import io.kotest.matchers.string.shouldBeEmpty42import io.kotest.matchers.string.shouldBeUpperCase43import io.kotest.matchers.string.shouldContain44import io.kotest.matchers.string.shouldNotBeBlank45import java.time.LocalDate46import org.junit.jupiter.api.Test47/**48 * Kotest assertions49 *50 * - [Kotest Assertions Documentation](https://kotest.io/assertions/)51 * - [Github](https://github.com/kotest/kotest/)52 */53class KotestAsserts {54 @Test55 fun `General assertions`() {56 "text" shouldBe "text"57 " ".shouldBeBlank()58 "hi".shouldNotBeBlank()59 "".shouldBeEmpty()60 "HI".shouldBeUpperCase()61 "hello".shouldContain("ll")62 true.shouldBeTrue()63 false.shouldBeFalse()64 null.shouldBeNull()65 10 shouldBeLessThan 1166 10 shouldBeLessThanOrEqual 1067 11 shouldBeGreaterThan 1068 11 shouldBeGreaterThanOrEqual 1169 10.shouldBeEven()70 0.shouldBeZero()71 }72 @Test73 fun `Exception assertions`() {74 shouldThrowExactly<IllegalStateException> {75 angryFunction()76 }77 shouldThrowAny {78 angryFunction()79 }80 }81 @Test82 fun `Collection assertions`() {83 emptyList<Int>().shouldBeEmpty()84 listOf(1, 2, 3) shouldContain 385 listOf(1, 2, 3).shouldBeSorted()86 listOf(1, 2, 3) shouldBeSameSizeAs listOf(4, 5, 6)87 1 shouldBeOneOf listOf(1, 2, 3)88 emptyMap<Int, String>().shouldBeEmpty()89 mapOf(1 to "one", 2 to "two", 3 to "three") shouldContainKey 190 mapOf(1 to "one", 2 to "two", 3 to "three") shouldContainValue "two"91 mapOf(1 to "one", 2 to "two", 3 to "three") shouldContain (3 to "three")92 }93 @Test94 fun `Arrow assertions`() {95 val optionNone = none<String>()96 val optionSome = Some("I am something").toOption()97 optionNone.shouldBeNone()98 optionSome.shouldBeSome()99 val rightEither = Either.Right(1)100 val leftEither = Either.Left("ERROR!!")101 rightEither.shouldBeRight()102 rightEither shouldBeRight 1103 leftEither.shouldBeLeft()104 leftEither shouldBeLeft "ERROR!!"105 val nonEmptyList = NonEmptyList.of(1, 2, 3, 4, 5, null)106 nonEmptyList shouldContain 1107 nonEmptyList.shouldContainNull()108 val valid = Validated.valid()109 val invalid = Validated.invalid()110 valid.shouldBeValid()111 invalid.shouldBeInvalid()112 }113 @Test114 fun `Json assertions`() {115 val jsonString = "{\"test\": \"property\", \"isTest\": true }"116 jsonString shouldMatchJson jsonString117 jsonString shouldContainJsonKey "$.test"118 jsonString shouldNotContainJsonKey "$.notTest"119 jsonString.shouldContainJsonKeyValue("$.isTest", true)120 }121 @Test122 fun `Custom assertions`() {123 val sentMail = Mail(124 dateCreated = LocalDate.of(2020, 10, 27),125 sent = true, message = "May you have an amazing day"126 )127 val unsentMail = Mail(128 dateCreated = LocalDate.of(2020, 10, 27),129 sent = false, message = "May you have an amazing day"130 )131 // This is possible132 sentMail.sent should beSent()133 unsentMail.sent shouldNot beSent()134 // This is recommended135 sentMail.shouldBeSent()136 unsentMail.shouldNotBeSent()137 }138 @Test139 fun `withClue usage`() {140 val mail = Mail(141 dateCreated = LocalDate.of(2020, 10, 27),142 sent = false, message = "May you have an amazing day"143 )144 withClue("sent field should be false") {145 mail.sent shouldBe false146 }147 mail.asClue {148 it.dateCreated shouldBeAfter LocalDate.of(2020, 10, 26)149 it.sent shouldBe false150 }151 }152 @Test153 fun `asClue usage`() {154 val mail = Mail(155 dateCreated = LocalDate.of(2020, 10, 27),156 sent = false, message = "May you have an amazing day"157 )158 mail.asClue {159 it.dateCreated shouldBeAfter LocalDate.of(2020, 10, 26)160 it.sent shouldBe false161 }162 }163 fun beSent() = object : Matcher<Boolean> {164 override fun test(value: Boolean) = MatcherResult(value, "Mail.sent should be true", "Mail.sent should be false")165 }166 fun Mail.shouldBeSent() = this.sent should beSent()167 fun Mail.shouldNotBeSent() = this.sent shouldNot beSent()168}169data class Mail(val dateCreated: LocalDate, val sent: Boolean, val message: String)170fun angryFunction() {171 throw IllegalStateException("How dare you!")172}...

Full Screen

Full Screen

WordRiddleSpec.kt

Source:WordRiddleSpec.kt Github

copy

Full Screen

...31 Then("The riddle should have $letter left") {32 left shouldBe true33 }34 }35 When("Guess lower case ${letter.lowercaseChar()}") {36 riddle.guess(letter)37 Then("Guessed letters should contain $letter") {38 guessedLetters shouldContain letter.lowercaseChar()39 }40 }41 When("Guess upper case ${letter.uppercaseChar()}") {42 riddle.guess(letter)43 Then("Guessed letters should contain $letter") {44 guessedLetters shouldContain letter.lowercaseChar()45 }46 }47 }48 And("Another letter") {49 val letter = 'a'50 When("Check if $letter is left") {51 val left = riddle.left(letter)52 Then("The riddle should not have $letter left") {53 left shouldNotBe true54 }55 }56 When("Guess $letter") {57 riddle.guess(letter)58 Then("$letter should not be guessed") {...

Full Screen

Full Screen

RandomServiceTest.kt

Source:RandomServiceTest.kt Github

copy

Full Screen

...77 }78 context("calling nextChar()") {79 val source = "qwertyuiopasdfghjklzxcvbnm"80 context("upperCase is true") {81 it("random upper-case letter is generated") {82 val letter = randomService.nextLetter(true).toString()83 source.toUpperCase() shouldContain letter84 }85 }86 context("upperCase is false") {87 it("random lower-case letter is generated") {88 val letter = randomService.nextLetter(false).toString()89 source shouldContain letter90 }91 }92 }93 }94})...

Full Screen

Full Screen

BotTest.kt

Source:BotTest.kt Github

copy

Full Screen

1package me.aksenov.whidbot.telegram2import io.kotest.core.spec.style.FunSpec3import io.kotest.core.test.TestCase4import io.kotest.core.test.TestResult5import io.kotest.extensions.spring.SpringExtension6import io.kotest.matchers.should7import io.kotest.matchers.shouldBe8import io.kotest.matchers.shouldNotBe9import me.aksenov.whidbot.task.dao.TaskDao10import me.aksenov.whidbot.task.model.TaskStatus11import org.springframework.boot.test.context.SpringBootTest12import org.telegram.telegrambots.meta.api.objects.CallbackQuery13import org.telegram.telegrambots.meta.api.objects.Chat14import org.telegram.telegrambots.meta.api.objects.Message15import org.telegram.telegrambots.meta.api.objects.Update16@SpringBootTest17class BotTest(private val botService: BotService, private val taskDao: TaskDao) : FunSpec() {18 override fun extensions() = listOf(SpringExtension)19 override fun afterTest(testCase: TestCase, result: TestResult) {20 taskDao.deleteAll()21 }22 init {23 test("bot should create task") {24 botService.processUpdate(update)25 taskDao.getAllByMessageAndTelegramId(update.message.text, update.message.chatId.toString()) should {26 it.size shouldBe 127 it.first() should { task ->28 task.message shouldBe update.message.text29 task.id shouldNotBe null30 task.started shouldNotBe null31 task.spentMinutes shouldBe 032 task.telegramId shouldBe update.message.chatId.toString()33 }34 }35 }36 test("task stop") {37 botService.processUpdate(update)38 val id = taskDao.getAllByMessageAndTelegramId(update.message.text, update.message.chatId.toString())39 .first().id!!40 botService.processUpdate(updateStop(id))41 taskDao.getById(id) should {42 it.updated shouldNotBe it.started43 it.status shouldBe TaskStatus.STOPPED44 }45 }46 test("task continue") {47 botService.processUpdate(update)48 val id = taskDao.getAllByMessageAndTelegramId(update.message.text, update.message.chatId.toString())49 .first().id!!50 botService.processUpdate(updateStop(id))51 botService.processUpdate(updateContinue(id))52 taskDao.getById(id) should {53 it.updated shouldNotBe it.started54 it.status shouldBe TaskStatus.IN_PROGRESS55 }56 }57 test("get today tasks") {58 botService.processUpdate(update)59 botService.getTodayTasks() should {60 it.size shouldBe 161 it.first() should { task ->62 task.chatId shouldBe update.message.chatId.toString()63 task.text.contains("test text old boy") shouldBe true64 }65 }66 }67 }68 private val update = Update().apply {69 message = Message().apply {70 text = "test text old boy"71 chat = Chat(111, "test chat")72 }73 }74 private fun updateStop(taskId: Long) = Update().apply {75 callbackQuery = CallbackQuery().apply {76 data = "${TaskStatus.STOPPED.command}$taskId"77 message = Message().apply {78 text = "lol"79 chat = Chat(111, "test chat")80 }81 }82 }83 private fun updateContinue(taskId: Long) = Update().apply {84 callbackQuery = CallbackQuery().apply {85 data = "${TaskStatus.IN_PROGRESS.command}$taskId"86 message = Message().apply {87 text = "lol"88 chat = Chat(111, "test chat")89 }90 }91 }92}...

Full Screen

Full Screen

MatcherTest.kt

Source:MatcherTest.kt Github

copy

Full Screen

1package com.psg.kotest_example2import io.kotest.core.spec.style.StringSpec3import io.kotest.matchers.collections.sorted4import io.kotest.matchers.maps.contain5import io.kotest.matchers.maps.haveKey6import io.kotest.matchers.maps.haveValue7import io.kotest.matchers.should8import io.kotest.matchers.shouldBe9import io.kotest.matchers.string.*10class MatcherTest : StringSpec() {11 init {12 // 'shouldBe' 동일함을 체크하는 Matcher 입니다.13 "hello world" shouldBe haveLength(11) // length가 11이어야 함을 체크 합니다.14 "hello" should include("ll") // 파라미터가 포함되어 있는지 체크 합니다.15 "hello" should endWith("lo") // 파라미터가 끝의 포함되는지 체크 합니다.16 "hello" should match("he...") // 파라미터가 매칭되는지 체크 합니다.17 "hello".shouldBeLowerCase() // 소문자로 작성되었는지 체크 합니다.18 val list = emptyList<String>()19 val list2 = listOf("aaa", "bbb", "ccc")20 val map = mapOf<String, String>(Pair("aa", "11"))21 list should beEmpty() // 원소가 비었는지 체크 합니다.22 list2 shouldBe sorted<String>() // 해당 자료형이 정렬 되었는지 체크 합니다.23 map should contain("aa", "11") // 해당 원소가 포함되었는지 체크 합니다.24 map should haveKey("aa") // 해당 key가 포함되었는지 체크 합니다.25 map should haveValue("11") // 해당 value가 포함되었는지 체크 합니다.26 }27}...

Full Screen

Full Screen

RecipeFilterServiceTest.kt

Source:RecipeFilterServiceTest.kt Github

copy

Full Screen

1package com.hellofresh.task1.service2import com.hellofresh.task1.getFakeMenu3import com.hellofresh.task1.model.Menu4import io.kotest.core.spec.style.StringSpec5import io.kotest.core.test.TestCase6import io.kotest.matchers.ints.shouldBeExactly7import io.kotest.matchers.shouldBe8import io.kotest.matchers.shouldNotBe9class RecipeFilterServiceTest : StringSpec() {10 private lateinit var menu: Menu11 private lateinit var filterService: IFilterService12 override fun beforeTest(testCase: TestCase) {13 super.beforeTest(testCase)14 menu = getFakeMenu()15 filterService = FilterService(menu)16 }17 init {18 "check that getRecipesByTag returns filtered recipes list"{19 val recipesList = filterService.filterRecipeByTag("hot")20 recipesList.size shouldNotBe 021 recipesList.size shouldBeExactly 322 }23 "check that getRecipesByTag returns empty list if recipes not found by tag"{24 val recipesList = filterService.filterRecipeByTag("high-calories")25 recipesList.size shouldBe 026 }27 }28}...

Full Screen

Full Screen

case

Using AI Code Generation

copy

Full Screen

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.shouldHaveLength8import io.kotest.matchers.string.shouldHaveMaxLength9import io.kotest.matchers.string.shouldHaveMinLength10import io.kotest.matchers.string.shouldMatch11import io.kotest.matchers.string.shouldNotMatch12import io.kotest.matchers.string.shouldBeLowerCase13import io.kotest.matchers.string.shouldBeUpperCase14import io.kotest.matchers.string.shouldBeEqualIgnoringCase15import io.kotest.matchers.string.shouldBeEqualNormalizingCase16import io.kotest.matchers.string.shouldBeEqualNormalizingWhitespace17import io.kotest.matchers.string.shouldBeEqualTrimmingWhitespace18import io.kotest.matchers.string.shouldBeEqual

Full Screen

Full Screen

case

Using AI Code Generation

copy

Full Screen

1import io.kotest.matchers.string.shouldContain2class StringSpecExample : StringSpec() { 3init { 4“string should contain substring” { 5} 6} 7}8import io.kotest.matchers.string.shouldContain9class StringSpecExample : StringSpec() { 10init { 11“string should contain substring” { 12} 13} 14}15import io.kotest.matchers.string.shouldContain16class StringSpecExample : StringSpec() { 17init { 18“string should contain substring” { 19} 20} 21}22import io.kotest.matchers.string.shouldContain23class StringSpecExample : StringSpec() { 24init { 25“string should contain substring” { 26} 27} 28}29import io.kotest.matchers.string.shouldContain30class StringSpecExample : StringSpec() { 31init { 32“string should contain substring” { 33} 34} 35}36import io.kotest.matchers.string.shouldContain37class StringSpecExample : StringSpec() { 38init { 39“string should contain substring” { 40} 41} 42}43import io.kotest.matchers.string.shouldContain44class StringSpecExample : StringSpec() { 45init { 46“string should contain substring” { 47} 48} 49}50import io.kotest.matchers.string.shouldContain51class StringSpecExample : StringSpec() { 52init { 53“string should contain substring” { 54} 55} 56}

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful