How to use test method of io.kotest.matchers.collections.empty class

Best Kotest code snippet using io.kotest.matchers.collections.empty.test

ServerTest.kt

Source:ServerTest.kt Github

copy

Full Screen

...21 * SOFTWARE.22 *23 */24package ttgamelib.net25import io.kotest.core.spec.style.FunSpec26import io.kotest.data.forAll27import io.kotest.data.row28import io.kotest.inspectors.forAll29import io.kotest.matchers.booleans.shouldBeFalse30import io.kotest.matchers.booleans.shouldBeTrue31import io.kotest.matchers.collections.shouldBeEmpty32import io.kotest.matchers.collections.shouldContain33import io.kotest.matchers.collections.shouldHaveSize34import io.kotest.matchers.maps.shouldContainValue35import io.kotest.matchers.shouldBe36import io.kotest.matchers.shouldNotBe37import io.kotest.matchers.types.shouldBeInstanceOf38import io.kotest.matchers.types.shouldBeTypeOf39import io.ktor.http.cio.websocket.*40import io.mockk.*41import kotlinx.serialization.json.Json42import ttgamelib.GameEngine43private inline fun<reified T: Packet> List<Frame>.decode(): List<T> {44 return map {45 Json.decodeFromString(Packet.serializer(), (it as Frame.Text).readText()) as T46 }47}48private fun createConnection(userName: String, clientId: Int): Pair<ClientConnection, MutableList<Frame>> {49 val sentPackets = mutableListOf<Frame>()50 val session = mockk<DefaultWebSocketSession>().also {51 coEvery {52 it.send(capture(sentPackets))53 } just Runs54 }55 val connection = ClientConnection(session).apply {56 name = userName57 id = clientId58 }59 return connection to sentPackets60}61internal class ServerTest : FunSpec({62 val engine = mockk<GameEngine>(relaxed = true)63 val (connection, sentPackets) = createConnection("player1", 1)64 lateinit var server: Server65 beforeEach {66 sentPackets.clear()67 }68 context("SendNamePacket") {69 val userName = "New User"70 server = Server("localhost", 1000, engine)71 test("should create new user if name is not in use") {72 server.handlePacket(SendNamePacket(userName), connection)73 val sent = sentPackets.decode<Packet>()74 sent[0].shouldBeInstanceOf<InitClientPacket>()75 (sent[0] as InitClientPacket).clientId shouldBe connection.id76 sent[1].shouldBeInstanceOf<ChatMessagePacket>()77 coVerify {78 engine.playerConnected(connection.id, userName)79 }80 }81 test("should request another name if in use") {82 val (connection2, sentPackets2) = createConnection("player2", 2)83 server.handlePacket(SendNamePacket(userName), connection2)84 val sent = sentPackets2.decode<SuggestNamePacket>()85 with (sent[0]) {86 name shouldNotBe userName87 taken.shouldContain(userName)88 disconnected.shouldBeFalse()89 }90 }91 test("should check for reconnection if disconnected") {92 server.connections.remove(connection.id)93 server.handlePacket(SendNamePacket(userName), connection)94 val sent = sentPackets.decode<SuggestNamePacket>()95 with (sent[0]) {96 name shouldNotBe userName97 taken.shouldContain(userName)98 disconnected.shouldBeTrue()99 }100 }101 test("should replace player on reconnection") {102 server.handlePacket(SendNamePacket(userName, true), connection)103 val sent = sentPackets.decode<Packet>()104 sent[0].shouldBeInstanceOf<InitClientPacket>()105 (sent[0] as InitClientPacket).clientId shouldBe connection.id106 sent[1].shouldBeInstanceOf<ChatMessagePacket>()107 coVerify {108 engine.playerReconnected(connection.id)109 }110 }111 test("should not replace player that is connected") {112 server.handlePacket(SendNamePacket(userName, true), connection)113 val sent = sentPackets.decode<SuggestNamePacket>()114 with (sent[0]) {115 name shouldNotBe userName116 disconnected.shouldBeFalse()117 }118 }119 }120 test("GameCommandPacket should be sent to game engine") {121 val packet = MessagePacket(object : GameMessage{})122 server.handlePacket(packet, connection)123 sentPackets.shouldBeEmpty()124 coVerify {125 engine.handle(connection.id, packet)126 }127 }128 context("chat command") {129 server = Server("localhost", 1000, engine)130 val connections = mutableListOf<ClientConnection>()131 val outgoing = mutableListOf<MutableList<Frame>>()132 for (i in 1..3) {133 with (createConnection("player$i", i)) {134 connections += first135 outgoing += second136 server.handlePacket(SendNamePacket(first.name), first)137 }138 }139 beforeEach {140 outgoing.forEach { it.clear() }141 }142 test("there should be three connected players") {143 connections.forAll {144 server.connections.shouldContainValue(it)145 }146 }147 test("emote should send message to all users") {148 forAll(149 row("/em is here"),150 row("/me is here")151 ) { msg ->152 server.handlePacket(ChatCommandPacket(connection.id, msg), connection)153 }154 outgoing.forEach {155 with (it.decode<ChatMessagePacket>()) {156 shouldHaveSize(2)157 forAll { it.message.shouldBeTypeOf<EmoteMessage>() }158 }159 }160 }161 test("whisper should send message to one user") {162 server.handlePacket(ChatCommandPacket(connections[0].id, "/w player2 a secret"), connections[0])163 outgoing[0].shouldHaveSize(1)164 outgoing[1].shouldHaveSize(1)165 outgoing[2].shouldBeEmpty()166 }167 test("whisper to unknown user should send info message to sender") {168 server.handlePacket(ChatCommandPacket(connections[1].id, "/w nobody a secret"), connections[1])169 outgoing[0].shouldHaveSize(0)170 outgoing[2].shouldHaveSize(0)171 outgoing[1].shouldHaveSize(1)172 outgoing[1].decode<ChatMessagePacket>().forAll {173 it.message.shouldBeTypeOf<InfoMessage>()174 }175 }176 test("unknown command should send info message to sender") {177 server.handlePacket(ChatCommandPacket(connections[1].id, "/foo bar baz"), connections[1])178 outgoing[0].shouldHaveSize(0)179 outgoing[2].shouldHaveSize(0)180 outgoing[1].shouldHaveSize(1)181 outgoing[1].decode<ChatMessagePacket>().forAll {182 it.message.shouldBeTypeOf<InfoMessage>()183 }184 }185 }186})...

Full Screen

Full Screen

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

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

RoomsKtTest.kt

Source:RoomsKtTest.kt Github

copy

Full Screen

1package com.tylerkindy.betrayal.db2import com.tylerkindy.betrayal.Direction3import io.kotest.assertions.throwables.shouldThrow4import io.kotest.core.spec.style.DescribeSpec5import io.kotest.matchers.collections.shouldBeEmpty6import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder7import io.kotest.matchers.should8import io.kotest.matchers.shouldBe9import io.kotest.property.Arb10import io.kotest.property.Exhaustive11import io.kotest.property.arbitrary.ShortShrinker12import io.kotest.property.arbitrary.arbitrary13import io.kotest.property.arbitrary.enum14import io.kotest.property.arbitrary.set15import io.kotest.property.checkAll16import io.kotest.property.exhaustive.ints17import io.kotest.property.exhaustive.map18import io.kotest.property.forAll19import org.jetbrains.exposed.sql.insert20import org.jetbrains.exposed.sql.select21import org.jetbrains.exposed.sql.selectAll22import org.jetbrains.exposed.sql.transactions.transaction23import kotlin.random.nextInt24val directionSets = Arb.set(Arb.enum<Direction>(), 0..Direction.values().size)25val rotations = Exhaustive.ints(0..3).map { it.toShort() }26val invalidRotationValues = (Short.MIN_VALUE..Short.MAX_VALUE) - (0..3)27val invalidRotations = arbitrary(listOf(Short.MIN_VALUE, -1, 4, Short.MAX_VALUE), ShortShrinker) {28 it.random.nextInt(invalidRotationValues.indices).let { i -> invalidRotationValues[i] }.toShort()29}30class RoomsKtTest : DescribeSpec({31 useDatabase()32 describe("returnRoomToStack") {...

Full Screen

Full Screen

MultimapTests.kt

Source:MultimapTests.kt Github

copy

Full Screen

1package com.adidas.mvi2import io.kotest.assertions.assertSoftly3import io.kotest.core.spec.IsolationMode4import io.kotest.core.spec.style.BehaviorSpec5import io.kotest.matchers.collections.shouldBeEmpty6import io.kotest.matchers.collections.shouldContain7import io.kotest.matchers.collections.shouldHaveSize8import io.kotest.matchers.collections.shouldNotContain9import io.kotest.matchers.shouldBe10internal class MultimapTests : BehaviorSpec({11 isolationMode = IsolationMode.InstancePerLeaf12 given("An empty multimap") {13 val multimap = Multimap<String, Int>()14 `when`("I put a value") {15 val entry = multimap.put("Test", 1)16 then("The value should be returned") {17 entry shouldBe MultimapEntry("Test", 1)18 }19 then("The value should be in the map") {20 assertSoftly(multimap["Test"]) {21 shouldHaveSize(1)22 shouldContain(MultimapEntry("Test", 1))23 }...

Full Screen

Full Screen

UserApiV1Test.kt

Source:UserApiV1Test.kt Github

copy

Full Screen

1package io.andrewohara.tabbychat.protocol.v1.api2import dev.forkhandles.result4k.valueOrNull3import dev.mrbergin.kotest.result4k.shouldBeFailure4import dev.mrbergin.kotest.result4k.shouldBeSuccess5import io.andrewohara.tabbychat.*6import io.andrewohara.tabbychat.auth.Realm7import io.andrewohara.tabbychat.contacts.TokenData8import io.andrewohara.tabbychat.protocol.v1.client.UserClientV19import io.andrewohara.tabbychat.protocol.v1.toDtoV110import io.andrewohara.utils.jdk.minus11import io.kotest.matchers.collections.shouldBeEmpty12import io.kotest.matchers.collections.shouldContainExactly13import io.kotest.matchers.collections.shouldHaveSize14import io.kotest.matchers.nulls.shouldBeNull15import io.kotest.matchers.shouldBe16import org.http4k.core.Uri17import org.junit.jupiter.api.Test18import java.time.Duration19class UserApiV1Test {20 private val driver = TestDriver()21 private val provider = driver.createProvider(Realm(Uri.of("http://tabby.chat")))22 private val self = provider.createUser("self")23 private val selfToken: TokenData = provider.service.createAccessToken(self.id).valueOrNull()!!24 private val contact = provider.createUser("contact").also {25 driver.givenContacts(self, it)26 }27 private val other = provider.createUser("other")28 private val client = UserClientV1(selfToken.toDtoV1(), provider)29 @Test...

Full Screen

Full Screen

LibraryRepositoryTest.kt

Source:LibraryRepositoryTest.kt Github

copy

Full Screen

2import com.noto.app.util.repositoryModule3import com.noto.app.domain.model.Library4import com.noto.app.domain.repository.LibraryRepository5import com.noto.app.fakeLocalDataSourceModule6import io.kotest.core.spec.style.StringSpec7import io.kotest.matchers.collections.shouldBeEmpty8import io.kotest.matchers.collections.shouldContain9import io.kotest.matchers.collections.shouldHaveSize10import io.kotest.matchers.collections.shouldNotBeEmpty11import io.kotest.matchers.string.shouldBeEqualIgnoringCase12import kotlinx.coroutines.flow.single13import org.koin.core.context.startKoin14import org.koin.core.context.stopKoin15import org.koin.test.KoinTest16import org.koin.test.get17class LibraryRepositoryTest : StringSpec(), KoinTest {18 private lateinit var repository: LibraryRepository19 init {20 beforeTest {21 startKoin {22 modules(fakeLocalDataSourceModule, repositoryModule)23 }24 repository = get()25 }26 afterTest {27 stopKoin()28 }29 "get all libraries should be empty" {30 repository.getLibraries()...

Full Screen

Full Screen

Kotest.kt

Source:Kotest.kt Github

copy

Full Screen

1package io.kotest.plugin.pitest2import io.kotest.core.spec.style.FunSpec3import io.kotest.core.spec.style.StringSpec4import io.kotest.core.spec.style.WordSpec5import io.kotest.matchers.collections.shouldBeEmpty6import io.kotest.matchers.collections.shouldHaveSize7import io.kotest.matchers.shouldBe8class Kotest : FunSpec() {9 init {10 test("StringSpecs") {11 val resultCollector = findTestsIn(StringSpecs::class.java)12 resultCollector.skipped.shouldBeEmpty()13 resultCollector.started.shouldHaveSize(2)14 resultCollector.ended.shouldHaveSize(2)15 resultCollector.failures.shouldHaveSize(1)16 }17 test("FunSpecs") {18 val resultCollector = findTestsIn(FunSpecs::class.java)19 resultCollector.skipped.shouldBeEmpty()20 resultCollector.started.shouldHaveSize(2)21 resultCollector.ended.shouldHaveSize(2)22 resultCollector.failures.shouldHaveSize(1)23 }24 test("WordSpecs") {25 val resultCollector = findTestsIn(WordSpecs::class.java)26 resultCollector.skipped.shouldBeEmpty()27 resultCollector.started.shouldHaveSize(7)28 resultCollector.ended.shouldHaveSize(7)29 resultCollector.failures.shouldHaveSize(2)30 }31 }32 private fun findTestsIn(clazz: Class<*>): TestResultCollector {33 val resultCollector = TestResultCollector()34 KotestUnitFinder().findTestUnits(clazz)35 .stream()36 .forEach { testUnit -> testUnit.execute(resultCollector) }37 return resultCollector38 }39}40private class FunSpecs : FunSpec() {41 init {42 test("passing test") { 1 shouldBe 1 }43 test("failing test") { 1 shouldBe 2 }44 }45}46private class StringSpecs : StringSpec() {47 init {48 "passing test" { 1 shouldBe 1 }49 "failing test" { 1 shouldBe 2 }50 }51}52private class WordSpecs : WordSpec() {53 init {54 "should container" should {55 "passing test" { 1 shouldBe 1 }56 "failing test" { 1 shouldBe 2 }57 }58 "when container" `when` {59 "nested should container" should {60 "passing test" { 1 shouldBe 1 }61 "failing test" { 1 shouldBe 2 }62 }63 }64 }65}...

Full Screen

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run Kotest automation tests on LambdaTest cloud grid

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

Most used method in empty

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful