Best Kotest code snippet using io.kotest.matchers.collections.containExactlyInAnyOrder.containExactlyInAnyOrder
ShouldContainExactlyTest.kt
Source:ShouldContainExactlyTest.kt  
2import io.kotest.assertions.shouldFail3import io.kotest.assertions.throwables.shouldThrow4import io.kotest.core.spec.style.WordSpec5import io.kotest.matchers.collections.containExactly6import io.kotest.matchers.collections.containExactlyInAnyOrder7import io.kotest.matchers.collections.shouldContainExactly8import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder9import io.kotest.matchers.collections.shouldNotContainExactly10import io.kotest.matchers.collections.shouldNotContainExactlyInAnyOrder11import io.kotest.matchers.should12import io.kotest.matchers.shouldBe13import io.kotest.matchers.shouldNot14import io.kotest.matchers.throwable.shouldHaveMessage15import java.io.File16import java.nio.file.Path17import java.nio.file.Paths18class ShouldContainExactlyTest : WordSpec() {19   init {20      "containExactly" should {21         "test that an array contains given elements exactly" {22            val actual = arrayOf(1, 2, 3)23            actual.shouldContainExactly(1, 2, 3)24            actual shouldContainExactly arrayOf(1, 2, 3)25            actual.shouldNotContainExactly(3, 2, 1)26            actual shouldNotContainExactly arrayOf(3, 2, 1)27            shouldThrow<AssertionError> {28               actual.shouldContainExactly(3, 2, 1)29            }30            shouldThrow<AssertionError> {31               actual shouldContainExactly arrayOf(3, 2, 1)32            }33            shouldThrow<AssertionError> {34               actual.shouldNotContainExactly(1, 2, 3)35            }36            shouldThrow<AssertionError> {37               actual shouldNotContainExactly arrayOf(1, 2, 3)38            }39            val actualNull: Array<Int>? = null40            shouldThrow<AssertionError> {41               actualNull.shouldContainExactly(1, 2, 3)42            }.shouldHaveMessage("Expecting actual not to be null")43            shouldThrow<AssertionError> {44               actualNull.shouldNotContainExactly()45            }.shouldHaveMessage("Expecting actual not to be null")46         }47         "test that a collection contains given elements exactly"  {48            val actual = listOf(1, 2, 3)49            emptyList<Int>() should containExactly()50            actual should containExactly(1, 2, 3)51            actual.shouldContainExactly(1, 2, 3)52            actual.toSet().shouldContainExactly(linkedSetOf(1, 2, 3))53            actual shouldNot containExactly(1, 2)54            actual.shouldNotContainExactly(3, 2, 1)55            actual.shouldNotContainExactly(listOf(5, 6, 7))56            shouldThrow<AssertionError> {57               actual should containExactly(1, 2)58            }59            shouldThrow<AssertionError> {60               actual should containExactly(1, 2, 3, 4)61            }62            shouldThrow<AssertionError> {63               actual.shouldContainExactly(3, 2, 1)64            }65         }66         "test contains exactly for byte arrays" {67            listOf("hello".toByteArray()) shouldContainExactly listOf("hello".toByteArray())68            listOf("helloworld".toByteArray()) shouldNotContainExactly listOf("hello".toByteArray())69         }70         "print errors unambiguously"  {71            shouldThrow<AssertionError> {72               listOf<Any>(1L, 2L).shouldContainExactly(listOf<Any>(1, 2))73            } shouldHaveMessage74               """75                  |Expecting: [1, 2] but was: [1L, 2L]76                  |Some elements were missing: [1, 2] and some elements were unexpected: [1L, 2L]77                  |expected:<[1, 2]> but was:<[1L, 2L]>78               """.trimMargin()79         }80         "informs user of illegal comparisons" {81            shouldFail {82               HashSet(setOf(1, 2, 3)) shouldContainExactly listOf(1, 2, 3)83            }.message shouldBe """Disallowed: Set can be compared only to Set84                           |May not compare HashSet with ArrayList85                           |expected:<*> but was:<*>86                           |87                           |""".trimMargin()88         }89         "print dataclasses" {90            shouldThrow<AssertionError> {91               listOf(92                  Blonde("foo", true, 23423, inputPath),93                  Blonde("woo", true, 97821, inputPath),94                  Blonde("goo", true, 51984, inputPath)95               ).shouldContainExactly(96                  Blonde("foo", true, 23423, inputPath),97                  Blonde("woo", true, 97821, inputPath)98               )99            }.message?.trim() shouldBe100               """101                  |Expecting: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=woo, b=true, c=97821, p=$expectedPath)] but was: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=woo, b=true, c=97821, p=$expectedPath), Blonde(a=goo, b=true, c=51984, p=$expectedPath)]102                  |Some elements were unexpected: [Blonde(a=goo, b=true, c=51984, p=$expectedPath)]103                  |expected:<[Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=woo, b=true, c=97821, p=$expectedPath)]> but was:<[Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=woo, b=true, c=97821, p=$expectedPath), Blonde(a=goo, b=true, c=51984, p=$expectedPath)]>104               """.trimMargin()105         }106         "include extras when too many" {107            shouldThrow<AssertionError> {108               listOf(109                  Blonde("foo", true, 23423, inputPath)110               ).shouldContainExactly(111                  Blonde("foo", true, 23423, inputPath),112                  Blonde("woo", true, 97821, inputPath)113               )114            }.message?.trim() shouldBe115               """116                  |Expecting: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=woo, b=true, c=97821, p=$expectedPath)] but was: [Blonde(a=foo, b=true, c=23423, p=$expectedPath)]117                  |Some elements were missing: [Blonde(a=woo, b=true, c=97821, p=$expectedPath)]118                  |expected:<[Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=woo, b=true, c=97821, p=$expectedPath)]> but was:<[Blonde(a=foo, b=true, c=23423, p=$expectedPath)]>119               """.trimMargin()120         }121         "include missing when too few" {122            shouldThrow<AssertionError> {123               listOf(124                  Blonde("foo", true, 23423, inputPath),125                  Blonde("hoo", true, 96915, inputPath)126               ).shouldContainExactly(127                  Blonde("woo", true, 97821, inputPath)128               )129            }.message?.trim() shouldBe130               """131                  |Expecting: [Blonde(a=woo, b=true, c=97821, p=$expectedPath)] but was: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=hoo, b=true, c=96915, p=$expectedPath)]132                  |Some elements were missing: [Blonde(a=woo, b=true, c=97821, p=$expectedPath)] and some elements were unexpected: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=hoo, b=true, c=96915, p=$expectedPath)]133                  |expected:<[Blonde(a=woo, b=true, c=97821, p=$expectedPath)]> but was:<[Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=hoo, b=true, c=96915, p=$expectedPath)]>134               """.trimMargin()135         }136         "include missing and extras when not the right amount" {137            shouldThrow<AssertionError> {138               listOf(139                  Blonde("foo", true, 23423, inputPath),140                  Blonde("hoo", true, 96915, inputPath)141               ).shouldContainExactly(142                  Blonde("woo", true, 97821, inputPath),143                  Blonde("goo", true, 51984, inputPath)144               )145            }.message?.trim() shouldBe146               """147                  |Expecting: [Blonde(a=woo, b=true, c=97821, p=$expectedPath), Blonde(a=goo, b=true, c=51984, p=$expectedPath)] but was: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=hoo, b=true, c=96915, p=$expectedPath)]148                  |Some elements were missing: [Blonde(a=woo, b=true, c=97821, p=$expectedPath), Blonde(a=goo, b=true, c=51984, p=$expectedPath)] and some elements were unexpected: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=hoo, b=true, c=96915, p=$expectedPath)]149                  |expected:<[Blonde(a=woo, b=true, c=97821, p=$expectedPath), Blonde(a=goo, b=true, c=51984, p=$expectedPath)]> but was:<[Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=hoo, b=true, c=96915, p=$expectedPath)]>150               """.trimMargin()151         }152      }153      "containExactlyInAnyOrder" should {154         "test that a collection contains given elements exactly in any order"  {155            val actual = listOf(1, 2, 3)156            actual should containExactlyInAnyOrder(1, 2, 3)157            actual.shouldContainExactlyInAnyOrder(3, 2, 1)158            actual.shouldContainExactlyInAnyOrder(linkedSetOf(2, 1, 3))159            actual shouldNot containExactlyInAnyOrder(1, 2)160            actual.shouldNotContainExactlyInAnyOrder(1, 2, 3, 4)161            actual.shouldNotContainExactlyInAnyOrder(listOf(5, 6, 7))162            actual.shouldNotContainExactlyInAnyOrder(1, 1, 1)163            actual.shouldNotContainExactlyInAnyOrder(listOf(2, 2, 3))164            actual.shouldNotContainExactlyInAnyOrder(listOf(1, 1, 2, 3))165            val actualDuplicates = listOf(1, 1, 2)166            actualDuplicates.shouldContainExactlyInAnyOrder(1, 2, 1)167            actualDuplicates.shouldContainExactlyInAnyOrder(2, 1, 1)168            actualDuplicates.shouldNotContainExactlyInAnyOrder(1, 2)169            actualDuplicates.shouldNotContainExactlyInAnyOrder(1, 2, 2)170            actualDuplicates.shouldNotContainExactlyInAnyOrder(1, 1, 2, 2)171            actualDuplicates.shouldNotContainExactlyInAnyOrder(1, 2, 7)172            shouldThrow<AssertionError> {173               actual should containExactlyInAnyOrder(1, 2)174            }175            shouldThrow<AssertionError> {176               actual should containExactlyInAnyOrder(1, 2, 3, 4)177            }178            shouldThrow<AssertionError> {179               actual should containExactlyInAnyOrder(1, 1, 1)180            }181            shouldThrow<AssertionError> {182               actual should containExactlyInAnyOrder(1, 1, 2, 3)183            }184            shouldThrow<AssertionError> {185               actualDuplicates should containExactlyInAnyOrder(1, 2, 2)186            }187         }188         "print errors unambiguously"  {189            shouldThrow<AssertionError> {190               listOf<Any>(1L, 2L).shouldContainExactlyInAnyOrder(listOf<Any>(1, 2))191            }.shouldHaveMessage("Collection should contain [1, 2] in any order, but was [1L, 2L]")192         }193         "disambiguate when using optional expected value" {194            val actual: List<String> = listOf("A", "B", "C")195            val expected: List<String>? = listOf("A", "B", "C")196            actual.shouldContainExactlyInAnyOrder(expected)197         }198      }199   }...SearchByNameViewModelSpec.kt
Source:SearchByNameViewModelSpec.kt  
1package net.subroh0508.colormaster.presentation.search.spec2import io.kotest.core.test.TestCase3import io.kotest.matchers.be4import io.kotest.matchers.collections.beEmpty5import io.kotest.matchers.collections.containExactlyInAnyOrder6import io.kotest.matchers.collections.haveSize7import io.kotest.matchers.nulls.beNull8import io.kotest.matchers.should9import kotlinx.coroutines.flow.launchIn10import kotlinx.coroutines.flow.onEach11import net.subroh0508.colormaster.model.*12import net.subroh0508.colormaster.presentation.search.MockIdolColorsRepository13import net.subroh0508.colormaster.presentation.search.everyRand14import net.subroh0508.colormaster.presentation.search.everySearchByName15import net.subroh0508.colormaster.presentation.search.model.IdolColorListItem16import net.subroh0508.colormaster.presentation.search.model.SearchUiModel17import net.subroh0508.colormaster.presentation.search.model.SearchParams18import net.subroh0508.colormaster.presentation.search.viewmodel.SearchByNameViewModel19import net.subroh0508.colormaster.test.TestScope20import net.subroh0508.colormaster.test.ViewModelSpec21class SearchByNameViewModelSpec : ViewModelSpec() {22    private val observedUiModels: MutableList<SearchUiModel> = mutableListOf()23    private val repository = MockIdolColorsRepository()24    lateinit var viewModel: SearchByNameViewModel25    override fun beforeTest(testCase: TestCase) {26        super.beforeTest(testCase)27        viewModel = SearchByNameViewModel(repository, TestScope()/* for JS Runtime */)28        observedUiModels.clear()29        viewModel.uiModel.onEach { observedUiModels.add(it) }30            .launchIn(TestScope())31    }32    private val randomIdols = listOf(33        IdolColor("Shimabara_Elena", "å³¶åã¨ã¬ã", HexColor("9BCE92")),34        IdolColor("Abe_nana", "å®é¨èã
", HexColor("E64A79")),35        IdolColor("Kohinata_Miho", "å°æ¥åç¾ç©", HexColor("C64796")),36        IdolColor("Sakuma_Mayu", "ä½ä¹
éã¾ã", HexColor("D1197B")),37        IdolColor("Hidaka_Ai", "æ¥é«æ", HexColor("E85786")),38        IdolColor("Nakatani_Iku", "ä¸è°·è²", HexColor("F7E78E")),39        IdolColor("Taiga_Takeru", "大河ã¿ã±ã«", HexColor("0E0C9F")),40        IdolColor("Kuzunoha_Amehiko", "èä¹èé¨å½¦", HexColor("111721")),41        IdolColor("Suou_Momoko", "å¨é²æ¡å", HexColor("EFB864")),42        IdolColor("Ichikawa_Hinana", "å¸å·éè", HexColor("FFC639")),43    )44    private val byName = IdolName("ä¹
å·")45    private val byNameIdols = listOf(46        IdolColor("Hisakawa_Nagi", "ä¹
å·åª", HexColor("F7A1BA")),47        IdolColor("Hisakawa_Hayate", "ä¹
å·é¢¯", HexColor("7ADAD6")),48    )49    private val byBrand = Brands._87650    private val byBrandIdols = listOf(51        IdolColor("Hidaka_Ai", "æ¥é«æ", HexColor("E85786")),52        IdolColor("Mizutani_Eri", "æ°´è°·çµµç", HexColor("00ADB9")),53        IdolColor("Akizuki_Ryo_876", "ç§ææ¶¼", HexColor("B2D468")),54    )55    56    private val byBrandAndType = Brands._765 to Types.MILLION_LIVE.PRINCESS57    private val byBrandAndTypeIdols = listOf(58        IdolColor("Amami_Haruka", "天海æ¥é¦", HexColor("E22B30")),59        IdolColor("Ganaha_Hibiki", "æé£è¦é¿", HexColor("01ADB9")),60        IdolColor("Kikuchi_Makoto", "èå°ç", HexColor("515558")),61        IdolColor("Hagiwara_Yukiho", "è©åéªæ©", HexColor("D3DDE9")),62    )63    private fun subject(block: () -> Unit): List<SearchUiModel> {64        block()65        return observedUiModels66    }67    private val emptyParams = SearchParams.ByName.EMPTY68    init {69        test("#search: when repository#rand returns idols colors it should post SearchUiModel with filled list") {70            repository.everyRand { randomIdols }71            subject(viewModel::search).also { models ->72                models should haveSize(3)73                models[0] should {74                    it.items should beEmpty()75                    it.error should beNull()76                    it.isLoading should be(false)77                }78                models[1] should {79                    it.items should beEmpty()80                    it.error should beNull()81                    it.isLoading should be(true)82                }83                models[2] should {84                    it.items should containExactlyInAnyOrder(randomIdols.map(::IdolColorListItem))85                    it.error should beNull()86                    it.isLoading should be(false)87                }88            }89        }90        test("#search: when repository#rand raise Exception it should post SearchUiModel with empty list") {91            val error = IllegalStateException()92            repository.everyRand { throw error }93            subject(viewModel::search).also { models ->94                models should haveSize(3)95                models[0] should {96                    it.items should beEmpty()97                    it.error should beNull()98                    it.isLoading should be(false)99                }100                models[1] should {101                    it.items should beEmpty()102                    it.error should beNull()103                    it.isLoading should be(true)104                }105                models[2] should {106                    it.items should beEmpty()107                    it.error should be(error)108                    it.isLoading should be(false)109                }110            }111        }112        test("#changeIdolNameSuggestQuery: when input name it should post SearchUiModel with filled list") {113            repository.everySearchByName(expectIdolName = byName) { _, _, _ -> byNameIdols }114            subject { viewModel.changeIdolNameSearchQuery(byName.value) }.also { models ->115                models should haveSize(4)116                models.last() should {117                    it.items should containExactlyInAnyOrder(byNameIdols.map(::IdolColorListItem))118                    it.params should be(emptyParams.copy(idolName = byName))119                }120            }121        }122        test("#setSearchParams: when change brand it should post SearchUiModel with filled list") {123            repository.everySearchByName(expectBrands = byBrand) { _, _, _ -> byBrandIdols }124            subject { viewModel.setSearchParams(emptyParams.change(byBrand)) }.also { models ->125                models should haveSize(4)126                models.last() should {127                    it.items should containExactlyInAnyOrder(byBrandIdols.map(::IdolColorListItem))128                    it.params should be(emptyParams.copy(brands = byBrand))129                }130            }131        }132        test("#setSearchParams: when change brand and type it should post SearchUiModel with filled list") {133            val (brand, type) = byBrandAndType134            repository.everySearchByName(expectBrands = brand, expectTypes = setOf(type)) { _, _, _ -> byBrandAndTypeIdols }135            subject { viewModel.setSearchParams(emptyParams.change(brand).change(type, checked = true)) }.also { models ->136                models should haveSize(4)137                models.last() should {138                    it.items should containExactlyInAnyOrder(byBrandAndTypeIdols.map(::IdolColorListItem))139                    it.params should be(emptyParams.copy(brands = brand, types = setOf(type)))140                }141            }142        }143        test("#select: when change selected item it should post SearchUiModel with select state") {144            repository.everyRand { randomIdols }145            subject {146                viewModel.search()147                viewModel.select(randomIdols[0], true)148                viewModel.select(randomIdols[0], false)149            }.also { models ->150                models should haveSize(5)151                models[models.lastIndex - 1] should {152                    it.items should haveSize(randomIdols.size)153                    it.selectedItems should be(listOf(randomIdols[0]))154                }155                models.last() should {156                    it.items should haveSize(randomIdols.size)157                    it.selectedItems should beEmpty()158                }159            }160        }161        test("#selectAll: when change selected item it should post SearchUiModel with select state") {162            repository.everyRand { randomIdols }163            subject {164                viewModel.search()165                viewModel.selectAll(true)166                viewModel.selectAll(false)167            }.also { models ->168                models should haveSize(5)169                models[models.lastIndex - 1] should {170                    it.items should haveSize(randomIdols.size)171                    it.selectedItems should containExactlyInAnyOrder(randomIdols)172                }173                models.last() should {174                    it.items should haveSize(randomIdols.size)175                    it.selectedItems should beEmpty()176                }177            }178        }179    }180}...ParallelStatesTest.kt
Source:ParallelStatesTest.kt  
1package ru.nsk.kstatemachine2import io.kotest.assertions.throwables.shouldThrow3import io.kotest.core.spec.style.StringSpec4import io.kotest.matchers.booleans.shouldBeTrue5import io.kotest.matchers.collections.containExactlyInAnyOrder6import io.kotest.matchers.should7import io.kotest.matchers.shouldBe8import io.mockk.verify9import io.mockk.verifySequence10class ParallelStatesTest : StringSpec({11    "initial state in parallel mode negative" {12        createStateMachine {13            initialState(childMode = ChildMode.PARALLEL) {14                shouldThrow<IllegalStateException> { initialState() }15            }16        }17    }18    "final state in parallel mode negative" {19        createStateMachine(childMode = ChildMode.PARALLEL) {20            shouldThrow<IllegalArgumentException> {21                finalState()22            }23        }24    }25    "parallel state machine" {26        val callbacks = mockkCallbacks()27        lateinit var state1: State28        lateinit var state2: State29        val machine = createStateMachine(childMode = ChildMode.PARALLEL) {30            callbacks.listen(this)31            state1 = state { callbacks.listen(this) }32            state2 = state { callbacks.listen(this) }33        }34        verifySequence {35            callbacks.onEntryState(machine)36            callbacks.onEntryState(state1)37            callbacks.onEntryState(state2)38        }39        machine.activeStates() should containExactlyInAnyOrder(machine, state1, state2)40        machine.isActive.shouldBeTrue()41        state1.isActive.shouldBeTrue()42        state2.isActive.shouldBeTrue()43    }44    "enter parallel states" {45        val callbacks = mockkCallbacks()46        lateinit var state1: State47        lateinit var state11: State48        lateinit var state12: State49        lateinit var state111: State50        val machine = createStateMachine {51            state1 = initialState(childMode = ChildMode.PARALLEL) {52                callbacks.listen(this)53                state11 = state {54                    callbacks.listen(this)55                    state111 = initialState { callbacks.listen(this) }56                }57                state12 = state { callbacks.listen(this) }58            }59        }60        verifySequence {61            callbacks.onEntryState(state1)62            callbacks.onEntryState(state11)63            callbacks.onEntryState(state111)64            callbacks.onEntryState(state12)65        }66        machine.activeStates() should containExactlyInAnyOrder(machine, state1, state11, state12, state111)67    }68    "exit parallel states" {69        val callbacks = mockkCallbacks()70        lateinit var state1: State71        lateinit var state2: State72        lateinit var state11: State73        lateinit var state12: State74        val machine = createStateMachine {75            state1 = initialState("state1", childMode = ChildMode.PARALLEL) {76                callbacks.listen(this)77                state11 = state("state11") { callbacks.listen(this) }78                state12 = state("state12") { callbacks.listen(this) }79                transitionOn<SwitchEvent> { targetState = { state2 } }80            }...IdolColorsRepositorySpec.kt
Source:IdolColorsRepositorySpec.kt  
1package net.subroh0508.colormaster.repository.spec2import io.kotest.core.spec.style.FunSpec3import io.kotest.matchers.collections.containExactlyInAnyOrder4import io.kotest.matchers.should5import io.ktor.client.*6import net.subroh0508.colormaster.api.imasparql.di.Api7import net.subroh0508.colormaster.model.*8import net.subroh0508.colormaster.model.ui.commons.AppPreference9import net.subroh0508.colormaster.model.ui.commons.ThemeType10import net.subroh0508.colormaster.repository.IdolColorsRepository11import net.subroh0508.colormaster.repository.di.IdolColorsRepositories12import net.subroh0508.colormaster.repository.mock.*13import org.koin.dsl.koinApplication14import org.koin.dsl.module15class IdolColorsRepositorySpec : FunSpec() {16    private fun mockApi(17        languages: Languages,18        block: () -> HttpClient,19    ): IdolColorsRepository = koinApplication {20        val appPreference: AppPreference = object : AppPreference {21            override val themeType: ThemeType? = null22            override val lang = languages23            override fun setThemeType(type: ThemeType) = Unit24            override fun setLanguage(lang: Languages) = Unit25        }26        modules(27            Api.Module(block()) + module {28                single { appPreference }29                single { mockAuthenticationClient }30                single { mockFirestoreClient }31            } + IdolColorsRepositories.Module32        )33    }.koin.get(IdolColorsRepository::class)34    init {35        Languages.values().forEach { lang ->36            test("#rand: when lang = '${lang.code}' it should return idols at random") {37                val repository = mockApi(lang) { mockRandom(lang, 10) }38                repository.rand(10) should containExactlyInAnyOrder(getRandomIdols(lang))39            }40            fun param(lang: Languages) = IdolName(if (lang == Languages.JAPANESE) "ä¹
å·" else "Hisakawa")41            fun expectsByName(lang: Languages) = listOf(42                IdolColor("Hisakawa_Nagi", if (lang == Languages.JAPANESE) "ä¹
å·åª" else "Nagi Hisakawa", HexColor("F7A1BA")),43                IdolColor("Hisakawa_Hayate", if (lang == Languages.JAPANESE) "ä¹
å·é¢¯" else "Hayate Hisakawa", HexColor("7ADAD6")),44            )45            test("#search(by name): when lang = '${lang.code}' it should return idols") {46                val repository = mockApi(lang) {47                    mockSearchByName(lang, param(lang), res = expectsByName(lang).toTypedArray())48                }49                repository.search(50                    name = param(lang),51                    brands = null,52                    types = setOf(),53                ) should containExactlyInAnyOrder(expectsByName(lang))54            }55            fun expectsByBrand(lang: Languages) = listOf(56                IdolColor("Hidaka_Ai", if (lang == Languages.JAPANESE) "æ¥é«æ" else "Ai Hidaka", HexColor("E85786")),57                IdolColor("Mizutani_Eri", if (lang == Languages.JAPANESE) "æ°´è°·çµµç" else "Eri Mizutani", HexColor("00ADB9")),58                IdolColor("Akizuki_Ryo_876", if (lang == Languages.JAPANESE) "ç§ææ¶¼" else "Ryo Akizuki", HexColor("B2D468")),59            )60            test("#search(by brand): when lang = '${lang.code}' it should return idols") {61                val repository = mockApi(lang) {62                    mockSearchByName(lang, brands = Brands._876, res = expectsByBrand(lang).toTypedArray())63                }64                repository.search(65                    name = null,66                    brands = Brands._876,67                    types = setOf(),68                ) should containExactlyInAnyOrder(expectsByBrand(lang))69            }70            fun expectsByBrandAndTypes(lang: Languages) = listOf(71                IdolColor("Amami_Haruka", if (lang == Languages.JAPANESE) "天海æ¥é¦" else "Haruka Amami", HexColor("E22B30")),72                IdolColor("Ganaha_Hibiki", if (lang == Languages.JAPANESE) "æé£è¦é¿" else "Ganaha Hibiki", HexColor("01ADB9")),73                IdolColor("Kikuchi_Makoto", if (lang == Languages.JAPANESE) "èå°ç" else "Kikuchi Makoto", HexColor("515558")),74                IdolColor("Hagiwara_Yukiho", if (lang == Languages.JAPANESE) "è©åéªæ©" else "Hagiwara Yukiho", HexColor("D3DDE9")),75            )76            test("#search(by brand and types): when lang = '${lang.code}' it should return idols") {77                val repository = mockApi(lang) {78                    mockSearchByName(lang, brands = Brands._765, types = setOf(Types.MILLION_LIVE.PRINCESS), res = expectsByBrandAndTypes(lang).toTypedArray())79                }80                repository.search(81                    name = null,82                    brands = Brands._765,83                    types = setOf(Types.MILLION_LIVE.PRINCESS),84                ) should containExactlyInAnyOrder(expectsByBrandAndTypes(lang))85            }86            fun expectsByLive(lang: Languages) = listOf(87                IdolColor("Sakuragi_Mano", if (lang == Languages.JAPANESE) "æ«»æ¨çä¹" else "Mano Sakuragi", HexColor("FFBAD6")),88                IdolColor("Kazano_Hiori", if (lang == Languages.JAPANESE) "風éç¯ç¹" else "Hirori Kazano", HexColor("144384")),89                IdolColor("Hachimiya_Meguru", if (lang == Languages.JAPANESE) "å
«å®®ããã" else "Meguru Hachimiya", HexColor("FFE012")),90            )91            test("#search(by live): when lang = '${lang.code}' it should return idols") {92                val live = LiveName("THE IDOLM@STER SHINY COLORS MUSIC DAWN Day1")93                val repository = mockApi(lang) {94                    mockSearchByLive(lang, LiveName("THE IDOLM@STER SHINY COLORS MUSIC DAWN Day1"), res = expectsByLive(lang).toTypedArray())95                }96                repository.search(live) should containExactlyInAnyOrder(expectsByLive(lang))97            }98            fun expectsById(lang: Languages) = listOf(99                IdolColor("Mitsumine_Yuika", if (lang == Languages.JAPANESE) "ä¸å³°çµè¯" else "Yuika Mitsumine", HexColor("3B91C4")),100                IdolColor("Hayami_Kanade", if (lang == Languages.JAPANESE) "éæ°´å¥" else "Kanade Hayami", HexColor("0D386D")),101            )102            test("#search(by id): when lang = '${lang.code}' it should return idols") {103                val ids = expectsById(lang).map(IdolColor::id)104                val repository = mockApi(lang) {105                    mockSearchById(lang, ids = ids, res = expectsById(lang).toTypedArray())106                }107                repository.search(ids = ids) should containExactlyInAnyOrder(expectsById(lang))108            }109        }110    }111}...ApiV1Test.kt
Source:ApiV1Test.kt  
2import io.andrewohara.cheetosbros.*3import io.andrewohara.cheetosbros.games.withHost4import io.kotest.matchers.be5import io.kotest.matchers.collections.containExactly6import io.kotest.matchers.collections.containExactlyInAnyOrder7import io.kotest.matchers.nulls.shouldNotBeNull8import io.kotest.matchers.shouldBe9import org.http4k.core.*10import org.http4k.kotest.shouldHaveBody11import org.http4k.kotest.shouldHaveStatus12import org.junit.jupiter.api.Test13class ApiV1Test {14    private val driver = TestDriver()15    private val userId = "1337"16    private val friendId = "9001"17    private fun Request.asUser(id: String) = header("Authorization", "Bearer $id")18    @Test19    fun `list games - unauthorized`() {20        val request = Request(Method.GET, "/v1/games")21        driver(request) shouldHaveStatus Status.UNAUTHORIZED22    }23    @Test24    fun `list games`() {25        val created = driver.createGame(userId, me3Data, me3AchievementData, emptyList())26        val response = Request(Method.GET, "/v1/games")27            .asUser(userId)28            .let(driver)29        response shouldHaveStatus Status.OK30        response.shouldHaveBody(ApiV1.Lenses.gamesList, containExactly(created.game.toDtoV1().withImageHost(testCdnHost)))31    }32    @Test33    fun `list achievements`() {34        val created = driver.createGame(userId, me3Data, me3AchievementData, emptyList())35        val response = Request(Method.GET, "/v1/games/${created.game.id}/achievements")36            .asUser(userId)37            .let(driver)38        response shouldHaveStatus Status.OK39        response.shouldHaveBody(ApiV1.Lenses.achievementList, containExactlyInAnyOrder(created.achievements.toDtoV1s().withImageHost(testCdnHost)))40    }41    @Test42    fun `get user - not available`() {43        val response = Request(Method.GET, "/v1/user")44            .asUser(userId)45            .let(driver)46        response shouldHaveStatus Status.NO_CONTENT47    }48    @Test49    fun `get user`() {50        val user = driver.steam.createUser("xxCheetoHunter420xx", avatar = Uri.of("https://slayer.jpg"))51        val response = Request(Method.GET, "/v1/user")52            .asUser(user.id)53            .let(driver)54        response shouldHaveStatus Status.OK55        response.shouldHaveBody(ApiV1.Lenses.user, be(user.toDtoV1()))56    }57    @Test58    fun `set game favourite - not found`() {59        Request(Method.PUT, "/v1/games/${godOfWarData.id}")60            .with(ApiV1.Lenses.updateGame of UpdateGameRequestV1(favourite = true))61            .asUser(userId)62            .let(driver)63            .shouldHaveStatus(Status.NOT_FOUND)64    }65    @Test66    fun `set game favourite`() {67        driver.createGame(userId, godOfWarData, emptyList(), emptyList())68        val response = Request(Method.PUT, "/v1/games/${godOfWarData.id}")69            .with(ApiV1.Lenses.updateGame of UpdateGameRequestV1(favourite = true))70            .asUser(userId)71            .let(driver)72        response shouldHaveStatus Status.OK73        ApiV1.Lenses.game(response).favourite shouldBe true74        driver.gamesDao[userId, godOfWarData.id].shouldNotBeNull()75            .favourite shouldBe true76    }77    @Test78    fun `set achievement favourite - not found`() {79        driver.createGame(userId, godOfWarData, emptyList(), emptyList())80        Request(Method.PUT, "/v1/games/${godOfWarData.id}/achievements/${godOfWarAchievement1Data.id}")81            .with(ApiV1.Lenses.updateGame of UpdateGameRequestV1(favourite = true))82            .asUser(userId)83            .let(driver)84            .shouldHaveStatus(Status.NOT_FOUND)85    }86    @Test87    fun `set achievement favourite`() {88        driver.createGame(userId, godOfWarData, listOf(godOfWarAchievement1Data), emptyList())89        val response = Request(Method.PUT, "/v1/games/${godOfWarData.id}/achievements/${godOfWarAchievement1Data.id}")90            .with(ApiV1.Lenses.updateGame of UpdateGameRequestV1(favourite = true))91            .asUser(userId)92            .let(driver)93        response shouldHaveStatus Status.OK94        ApiV1.Lenses.achievement(response).favourite shouldBe true95        driver.achievementsDao[userId, godOfWarData.id, godOfWarAchievement1Data.id].shouldNotBeNull()96            .favourite shouldBe true97    }98    @Test99    fun `get friends`() {100        val friend1 = driver.steam.createUser("tom")101        val friend2 = driver.steam.createUser("hank")102        driver.steam.addFriend(userId.toLong(), friendId = friend1.id.toLong())103        driver.steam.addFriend(userId.toLong(), friendId = friend2.id.toLong())104        val response = Request(Method.GET, "/v1/friends")105            .asUser(userId)106            .let(driver)107        response shouldHaveStatus Status.OK108        response.shouldHaveBody(ApiV1.Lenses.users, containExactlyInAnyOrder(109            friend1.toDtoV1(), friend2.toDtoV1()110        ))111    }112    @Test113    fun `get achievements for friend`() {114        driver.steam += godOfWarData115        driver.steam += godOfWarAchievement1Data116        driver.steam += godOfWarAchievement2Data117        driver.steam.unlockAchievement(friendId, godOfWarAchievement2Data, tNow)118        val response = Request(Method.GET, "/v1/games/${godOfWarData.id}/friends/$friendId/achievements")119            .asUser(userId)120            .let(driver)121        response shouldHaveStatus Status.OK122        response.shouldHaveBody(ApiV1.Lenses.achievementStatusList, containExactlyInAnyOrder(123            AchievementStatusDtoV1(id = godOfWarAchievement1Data.id, unlockedOn = null, unlocked = false),124            AchievementStatusDtoV1(id = godOfWarAchievement2Data.id, unlockedOn = tNow, unlocked = true)125        ))126    }127    private fun Collection<AchievementDtoV1>.withImageHost(host: Uri) = map {128        it.copy(129            iconLocked = Uri.of(it.iconLocked).withHost(host).toString(),130            iconUnlocked = Uri.of(it.iconUnlocked).withHost(host).toString()131        )132    }133    private fun GameDtoV1.withImageHost(host: Uri) = copy(134        displayImage = Uri.of(displayImage).withHost(host).toString()135    )136}...PolygonApiTests.kt
Source:PolygonApiTests.kt  
1package polygon2import io.kotest.core.spec.style.BehaviorSpec3import io.kotest.inspectors.forAll4import io.kotest.koin.KoinListener5import io.kotest.matchers.collections.containExactlyInAnyOrder6import io.kotest.matchers.collections.shouldBeEmpty7import io.kotest.matchers.nulls.shouldBeNull8import io.kotest.matchers.nulls.shouldNotBeNull9import io.kotest.matchers.should10import io.kotest.matchers.shouldBe11import org.koin.test.KoinTest12import org.koin.test.inject13import polygon.TestProblems.problemWithOnlyReadAccess14import polygon.TestProblems.problemWithTestGroups15import polygon.TestProblems.problemWithTestGroupsExceptSamples16import polygon.TestProblems.problemWithoutPdfStatement17import polygon.api.PolygonApi18import polygon.api.TestGroup.PointsPolicyType.COMPLETE_GROUP19import polygon.api.TestGroup.PointsPolicyType.EACH_TEST20import polygonModule21class PolygonApiTests : BehaviorSpec(), KoinTest {22    private val api: PolygonApi by inject()23    override fun listeners() = listOf(KoinListener(polygonModule))24    init {25        Given("getTestGroup") {26            When("asking for problem with test group on all tests") {27                suspend fun result() = api.getTestGroup(problemWithTestGroups).extract()28                val expectedGroups = listOf("samples", "first", "second", "third", "fourth", "fifth")29                Then("returns correct group names") {30                    result().map { it.name } should containExactlyInAnyOrder(expectedGroups)31                }32                Then("returns correct group dependencies") {33                    val byName = result().associateBy { it.name }34                    byName["second"].shouldNotBeNull().dependencies should containExactlyInAnyOrder("samples")35                    byName["third"].shouldNotBeNull().dependencies should containExactlyInAnyOrder("first", "fifth")36                    byName["fourth"].shouldNotBeNull().dependencies should containExactlyInAnyOrder("third")37                    (expectedGroups - setOf("second", "third", "fourth")).forAll {38                        byName[it].shouldNotBeNull().dependencies.shouldBeEmpty()39                    }40                }41                Then("all groups except fourth should have points policy of EACH_TEST") {42                    val result = result().associateBy { it.name }43                    result.entries.filter { it.key != "fourth" }.map { it.value }44                        .forAll { it.pointsPolicy shouldBe EACH_TEST }45                    result["fourth"].shouldNotBeNull().pointsPolicy shouldBe COMPLETE_GROUP46                }47                Then("fourth group should have points policy of COMPLETE_GROUP") {48                    result().single { it.name == "fourth" }.pointsPolicy shouldBe COMPLETE_GROUP49                }50            }51            When("asking for problem with test group on all tests except samples") {52                suspend fun result() = api.getTestGroup(problemWithTestGroupsExceptSamples).extract()53                val expectedGroups = listOf("first", "second", "third", "fourth", "fifth")54                Then("returns correct group names") {55                    result().map { it.name } should containExactlyInAnyOrder(expectedGroups)56                }57                Then("returns correct group dependencies") {58                    val byName = result().associateBy { it.name }59                    byName["third"].shouldNotBeNull().dependencies should containExactlyInAnyOrder("first", "fifth")60                    byName["fourth"].shouldNotBeNull().dependencies should containExactlyInAnyOrder("third")61                    (expectedGroups - setOf("third", "fourth")).forAll {62                        byName[it].shouldNotBeNull().dependencies.shouldBeEmpty()63                    }64                }65                Then("all groups except fourth should have points policy of EACH_TEST") {66                    val result = result().associateBy { it.name }67                    result.entries.filter { it.key != "fourth" }.map { it.value }68                        .forAll { it.pointsPolicy shouldBe EACH_TEST }69                    result["fourth"].shouldNotBeNull().pointsPolicy shouldBe COMPLETE_GROUP70                }71                Then("fourth group should have points policy of COMPLETE_GROUP") {72                    result().single { it.name == "fourth" }.pointsPolicy shouldBe COMPLETE_GROUP73                }74            }...CurrencyTest.kt
Source:CurrencyTest.kt  
1package dev.itbasis.kochange.core.currency2import io.kotest.core.spec.style.DescribeSpec3import io.kotest.datatest.withData4import io.kotest.matchers.collections.containExactlyInAnyOrder5import io.kotest.matchers.collections.shouldHaveSize6import io.kotest.matchers.maps.shouldHaveSize7import io.kotest.matchers.should8import io.kotest.matchers.shouldBe9import io.kotest.matchers.shouldNotBe10internal class CurrencyTest : DescribeSpec() {11	init {12		afterTest {13			Currency.resetCache()14		}15		describe("currency count") {16			it("every symbol") {17				withData(18					Pair("A", 29),19					Pair("B", 37),20					Pair("C", 26),21					Pair("D", 19),22					Pair("E", 16),23					Pair("F", 9),24					Pair("G", 14),25					Pair("H", 0),26					Pair("I", 0),27					Pair("J", 4),28					Pair("K", 2),29					Pair("L", 4),30					Pair("M", 11),31					Pair("N", 4),32					Pair("O", 5),33					Pair("P", 2),34					Pair("Q", 3),35					Pair("R", 3),36					Pair("S", 12),37					Pair("T", 2),38					Pair("U", 14),39					Pair("V", 2),40					Pair("W", 3),41					Pair("X", 8),42					Pair("Y", 3),43					Pair("Z", 3)44				) { (prefix, count) ->45					currencies.filterKeys {46						it.startsWith(prefix = prefix)47					}.keys.shouldHaveSize(count)48				}49			}50			it("total") {51				currencies.shouldHaveSize(235)52				Currency.all().shouldHaveSize(233)53			}54		}55		describe("alternative codes") {56			withData(57				Triple(BTC, XBT, listOf("XBT")),58				Triple(XBT, BTC, listOf("BTC"))59			) { (currency, equal, alternatives) ->60				currency.alternativeCodes should containExactlyInAnyOrder(alternatives)61				currency shouldBe equal62			}63		}64		describe("create new instance") {65			val nnn = Currency.getOrCreateInstance(code = "NNN", baseCurrency = XBT)66			nnn.code shouldBe "NNN"67			nnn.name shouldBe BTC.name68			nnn.alternativesAsInstances() should containExactlyInAnyOrder(BTC, XBT)69			nnn shouldBe BTC70			nnn shouldBe XBT71			val nnn1 = Currency.getOrCreateInstance(code = "NNN")72			nnn1.code shouldBe "NNN"73			nnn1.name shouldBe BTC.name74			nnn1.alternativesAsInstances() should containExactlyInAnyOrder(BTC, XBT)75			nnn1 shouldBe BTC76			nnn1 shouldBe XBT77			val nnn2 = Currency.getOrCreateInstance(code = "NNN", baseCurrency = LTC)78			nnn2.code shouldBe "NNN"79			nnn2.name shouldBe BTC.name80			nnn2.alternativesAsInstances() should containExactlyInAnyOrder(BTC, XBT)81			nnn2 shouldBe BTC82			nnn2 shouldBe XBT83		}84		describe("get instance not create") {85			it("exists") {86				data class TestData(87					val code: String,88					val expectCurrency: Currency,89					val expectName: String,90					val expectAlternatives: List<String> = emptyList()91				)92				withData(93					nameFn = { t: TestData -> "${t.code} -> ${t.expectCurrency}" },94					TestData(code = "BTC", expectCurrency = BTC, expectName = "Bitcoin", expectAlternatives = listOf("XBT")),95					TestData(code = "XBT", expectCurrency = XBT, expectName = "Bitcoin", expectAlternatives = listOf("BTC")),96					TestData(code = "AED", expectCurrency = AED, expectName = "United Arab Emirates Dirham"),97					TestData(code = "BRL", expectCurrency = BRL, expectName = "Brazilian Real", expectAlternatives = listOf("R$")),98					TestData(code = "R$", expectCurrency = BRL, expectName = "Brazilian Real", expectAlternatives = listOf("R$")),99					TestData(code = "COTI", expectCurrency = COTI, expectName = "COTI")100				) { (code, expectCurrency, expectName, expectAlternatives) ->101					val actual = Currency.getInstanceNotCreate(code = code)102					requireNotNull(actual)103					actual shouldBe expectCurrency104					actual.name shouldBe expectName105					actual.alternativeCodes should containExactlyInAnyOrder(expectAlternatives)106				}107				withData(108					Pair("BTC", BTC),109					Pair("btc", null),110					Pair("Btc", null),111					Pair("bTc", null),112					Pair("R$", BRL),113					Pair("r$", null),114					Pair("GHS", GHS),115// 				Pair("GHs", GHs),116					Pair("gHs", null)117				) { (code, currency) ->118					Currency.getInstanceNotCreate(code = code) shouldBe currency119				}...PreviewViewModelSpec.kt
Source:PreviewViewModelSpec.kt  
1package net.subroh0508.colormaster.presentation.preview.spec2import io.kotest.core.test.TestCase3import io.kotest.matchers.be4import io.kotest.matchers.collections.beEmpty5import io.kotest.matchers.collections.containExactlyInAnyOrder6import io.kotest.matchers.collections.haveSize7import io.kotest.matchers.nulls.beNull8import io.kotest.matchers.should9import kotlinx.coroutines.flow.launchIn10import kotlinx.coroutines.flow.onEach11import net.subroh0508.colormaster.model.*12import net.subroh0508.colormaster.presentation.preview.MockIdolColorsRepository13import net.subroh0508.colormaster.presentation.preview.mockSearch14import net.subroh0508.colormaster.presentation.preview.model.FullscreenPreviewUiModel15import net.subroh0508.colormaster.presentation.preview.viewmodel.PreviewViewModel16import net.subroh0508.colormaster.test.TestScope17import net.subroh0508.colormaster.test.ViewModelSpec18class PreviewViewModelSpec : ViewModelSpec() {19    private val observedUiModels: MutableList<FullscreenPreviewUiModel> = mutableListOf()20    private val repository = MockIdolColorsRepository()21    lateinit var viewModel: PreviewViewModel22    override fun beforeTest(testCase: TestCase) {23        super.beforeTest(testCase)24        viewModel = PreviewViewModel(repository, TestScope()/* for JS Runtime */)25        observedUiModels.clear()26        viewModel.uiModel.onEach { observedUiModels.add(it) }27            .launchIn(TestScope())28    }29    private fun subject(block: () -> Unit): List<FullscreenPreviewUiModel> {30        block()31        return observedUiModels32    }33    init {34        val idols = listOf(35            IdolColor("Mitsumine_Yuika", "ä¸å³°çµè¯", HexColor("3B91C4")),36            IdolColor("Hayami_Kanade", "éæ°´å¥", HexColor("0D386D")),37        )38        test("#fetch: when repository#search returns idols colors it should post FullscreenPreviewUiModel with filled list") {39            repository.mockSearch(idols.map(IdolColor::id)) { idols }40            subject { viewModel.fetch(idols.map(IdolColor::id)) }.also { models ->41                models should haveSize(3)42                models[0] should {43                    it.items should beEmpty()44                    it.error should beNull()45                    it.isLoading should be(false)46                }47                models[1] should {48                    it.items should beEmpty()49                    it.error should beNull()50                    it.isLoading should be(true)51                }52                models[2] should {53                    it.items should containExactlyInAnyOrder(idols)54                    it.error should beNull()55                    it.isLoading should be(false)56                }57            }58        }59        test("#fetch: when repository#search raises Exception it should post FullscreenPreviewUiModel with empty list") {60            val error = IllegalStateException()61            repository.mockSearch(idols.map(IdolColor::id)) { throw error }62            subject { viewModel.fetch(idols.map(IdolColor::id)) }.also { models ->63                models should haveSize(3)64                models[0] should {65                    it.items should beEmpty()66                    it.error should beNull()67                    it.isLoading should be(false)...containExactlyInAnyOrder
Using AI Code Generation
1val list = listOf(1, 2, 3, 4, 5)2list should containExactlyInAnyOrder(1, 2, 3, 4, 5)3list should containExactlyInAnyOrder(2, 1, 3, 4, 5)4list should containExactlyInAnyOrder(1, 2, 3, 4)5list should containExactlyInAnyOrder(1, 2, 3, 4, 5, 6)6list should containExactlyInAnyOrder(1, 2, 3, 4, 6)7list should containExactlyInAnyOrder(1, 2, 3, 4, 5, 6)8list should containExactlyInAnyOrder(1, 2, 3, 4, 6)9val list = listOf(1, 2, 3, 4, 5)10list should containExactlyInAnyOrder(1, 2, 3, 4, 5)11list should containExactlyInAnyOrder(2, 1, 3, 4, 5)12list should containExactlyInAnyOrder(1, 2, 3, 4)13list should containExactlyInAnyOrder(1, 2, 3, 4, 5, 6)14list should containExactlyInAnyOrder(1, 2, 3, 4, 6)15list should containExactlyInAnyOrder(1, 2, 3, 4, 5, 6)16list should containExactlyInAnyOrder(1, 2, 3, 4, 6)17val list = listOf(1, 2, 3, 4, 5)18list should containExactlyInAnyOrder(1, 2, 3, 4, 5)19list should containExactlyInAnyOrder(2, 1, 3, 4, 5)20list should containExactlyInAnyOrder(1, 2, 3, 4)21list should containExactlyInAnyOrder(1, 2containExactlyInAnyOrder
Using AI Code Generation
1val list1 = listOf("A", "B", "C")2val list2 = listOf("A", "B", "C")3list1 should containExactlyInAnyOrder(list2)4val list1 = listOf("A", "B", "C")5val list2 = listOf("A", "B", "C")6list1 should containExactlyInAnyOrder(list2)7val list1 = listOf("A", "B", "C")8val list2 = listOf("A", "B", "C")9list1 should containExactlyInAnyOrder(list2)10val list1 = listOf("A", "B", "C")11val list2 = listOf("A", "B", "C")12list1 should containExactlyInAnyOrder(list2)13val list1 = listOf("A", "B", "C")14val list2 = listOf("A", "B", "C")15list1 should containExactlyInAnyOrder(list2)16val list1 = listOf("A", "B", "C")17val list2 = listOf("A", "B", "C")18list1 should containExactlyInAnyOrder(list2)19val list1 = listOf("A", "B", "C")20val list2 = listOf("A", "B", "C")21list1 should containExactlyInAnyOrder(list2)22val list1 = listOf("A", "B", "C")23val list2 = listOf("A", "B", "C")24list1 should containExactlyInAnyOrder(list2)containExactlyInAnyOrder
Using AI Code Generation
1@DisplayName ( "Test for containExactlyInAnyOrder method" ) @Test fun testForContainExactlyInAnyOrder ( ) { val list = listOf ( 1 , 2 , 3 ) list should containExactlyInAnyOrder ( 3 , 2 , 1 ) }2@DisplayName ( "Test for containExactlyInAnyOrder method" ) @Test fun testForContainExactlyInAnyOrder ( ) { val list = listOf ( 1 , 2 , 3 ) list should containExactlyInAnyOrder ( 1 , 2 , 3 ) }3@DisplayName ( "Test for containExactlyInAnyOrder method" ) @Test fun testForContainExactlyInAnyOrder ( ) { val list = listOf ( 1 , 2 , 3 ) list should containExactlyInAnyOrder ( 3 , 2 , 1 ) }4@DisplayName ( "Test for containExactlyInAnyOrder method" ) @Test fun testForContainExactlyInAnyOrder ( ) { val list = listOf ( 1 , 2 , 3 ) list should containExactlyInAnyOrder ( 1 , 2 , 3 ) }5@DisplayName ( "Test for containExactlyInAnyOrder method" ) @Test fun testForContainExactlyInAnyOrder ( ) { val list = listOf ( 1 , 2 , 3 ) list should containExactlyInAnyOrder ( 3 , 2 , 1 ) }6@DisplayName ( "Test for containExactlyInAnyOrder method" ) @Test fun testForContainExactlyInAnyOrder ( ) { val list = listOf ( 1 , 2 , 3 ) list should containExactlyInAnyOrder ( 1 , 2 , 3 ) }7@DisplayName ( "Test for containExactlyInAnyOrder method" ) @Test fun testForContainExactlyInAnyOrder ( ) { val list = listOf ( 1 , 2 , 3 ) list should containExactlyInAnyOrder ( 3 , 2 , 1 ) }8@DisplayName ( "Test for containExactlyInAnyOrder method" ) @Test fun testForContainExactlyInAnyOrder ( ) { val list = listOf (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!!
