How to use failure method of io.kotest.matchers.internal class

Best Kotest code snippet using io.kotest.matchers.internal.failure

RedisHeimdallLightTest.kt

Source:RedisHeimdallLightTest.kt Github

copy

Full Screen

1package ch.sourcemotion.vertx.redis.client.heimdall2import ch.sourcemotion.vertx.redis.client.heimdall.RedisHeimdallException.Reason.ACCESS_DURING_RECONNECT3import ch.sourcemotion.vertx.redis.client.heimdall.RedisHeimdallException.Reason.CONNECTION_ISSUE4import ch.sourcemotion.vertx.redis.client.heimdall.testing.AbstractRedisTest5import io.kotest.assertions.throwables.shouldThrow6import io.kotest.matchers.collections.shouldBeIn7import io.kotest.matchers.collections.shouldHaveSize8import io.kotest.matchers.ints.shouldBeBetween9import io.kotest.matchers.nulls.shouldNotBeNull10import io.kotest.matchers.shouldBe11import io.kotest.matchers.types.shouldBeInstanceOf12import io.vertx.junit5.VertxTestContext13import io.vertx.kotlin.coroutines.await14import io.vertx.redis.client.Command15import io.vertx.redis.client.Request16import io.vertx.redis.client.Response17import kotlinx.coroutines.coroutineScope18import kotlinx.coroutines.delay19import kotlinx.coroutines.launch20import org.junit.jupiter.api.AfterEach21import org.junit.jupiter.api.Test22import kotlin.LazyThreadSafetyMode.NONE23internal class RedisHeimdallLightTest : AbstractRedisTest() {24 private val defaultOptions by lazy(NONE) { getDefaultRedisHeimdallOptions().setReconnectInterval(100) }25 @AfterEach26 internal fun tearDown() = asyncBeforeOrAfter {27 removeConnectionIssues()28 val client = RedisHeimdallLight(vertx, defaultOptions)29 client.send(Request.cmd(Command.FLUSHALL)).await()30 client.close()31 }32 @Test33 internal fun connect(testContext: VertxTestContext) = testContext.async {34 val sut = RedisHeimdallLight(vertx, defaultOptions).markAsTestClient()35 val expectedConnection = sut.connect().await()36 sut.connect().await().shouldBe(expectedConnection)37 sut.connect().await().shouldBe(expectedConnection)38 }39 @Test40 internal fun send_burst_on_startup(testContext: VertxTestContext) = testContext.async(10000) { checkpoint ->41 val sut = RedisHeimdallLight(vertx, defaultOptions.apply { redisOptions.maxWaitingHandlers = 10000 })42 .markAsTestClient()43 repeat(10000) { idx ->44 launch {45 sut.sendCmd().await().also {46 testContext.verifySendResponse(it, idx + 1)47 }48 checkpoint.flag()49 }50 }51 }52 @Test53 internal fun batch_burst_on_startup(testContext: VertxTestContext) = testContext.async(10000) { checkpoint ->54 val sut = RedisHeimdallLight(vertx, defaultOptions.apply { redisOptions.maxWaitingHandlers = 10000 })55 .markAsTestClient()56 repeat(10000) { idx ->57 launch {58 sut.sendBatch().await().also {59 testContext.verifyBatchResponse(it, idx + 1)60 }61 checkpoint.flag()62 }63 }64 }65 @Test66 internal fun send_reconnected_after_event(testContext: VertxTestContext) =67 testContext.async(1) { removeConnectionIssuesCheckpoint ->68 val commandAfterReconnectCheckpoint = testContext.checkpoint()69 val sut = RedisHeimdallLight(vertx, defaultOptions).markAsTestClient()70 vertx.eventBus().consumer<Unit>(defaultOptions.reconnectingStartNotificationAddress) {71 vertx.setTimer(defaultOptions.reconnectInterval) { removeConnectionIssues() }72 removeConnectionIssuesCheckpoint.flag()73 }74 vertx.eventBus().consumer<Unit>(defaultOptions.reconnectingSucceededNotificationAddress) {75 testScope.launch {76 runCatching {77 sut.sendCmd().await().also {78 testContext.verifySendResponse(it, 2)79 commandAfterReconnectCheckpoint.flag()80 }81 }82 }83 }84 sut.sendCmd().await().also { testContext.verifySendResponse(it, 1) }85 closeConnection()86 shouldThrow<RedisHeimdallException> { sut.sendCmd().await() }87 }88 @Test89 internal fun batch_reconnected_after_event(testContext: VertxTestContext) =90 testContext.async(1) { removeConnectionIssuesCheckpoint ->91 val commandAfterReconnectCheckpoint = testContext.checkpoint()92 val sut = RedisHeimdallLight(vertx, defaultOptions).markAsTestClient()93 vertx.eventBus().consumer<Unit>(defaultOptions.reconnectingStartNotificationAddress) {94 vertx.setTimer(defaultOptions.reconnectInterval) { removeConnectionIssues() }95 removeConnectionIssuesCheckpoint.flag()96 }97 vertx.eventBus().consumer<Unit>(defaultOptions.reconnectingSucceededNotificationAddress) {98 testScope.launch {99 runCatching {100 sut.sendBatch().await().also {101 testContext.verifyBatchResponse(it, 2)102 commandAfterReconnectCheckpoint.flag()103 }104 }105 }106 }107 sut.sendBatch().await().also { testContext.verifyBatchResponse(it, 1) }108 closeConnection()109 shouldThrow<RedisHeimdallException> { sut.sendBatch().await() }110 }111 @Test112 internal fun send_connection_issue_before_create(testContext: VertxTestContext) =113 testContext.async(1000) { checkpoint ->114 closeConnection()115 val sut = RedisHeimdallLight(vertx, defaultOptions).markAsTestClient()116 repeat(1000) {117 launch {118 sut.sendCmd().onFailure {119 testContext.verify {120 val cause = it.shouldBeInstanceOf<RedisHeimdallException>()121 cause.reason.shouldBe(CONNECTION_ISSUE)122 }123 checkpoint.flag()124 }.onSuccess { testContext.failNow("Commands on initial connection issue should fail") }125 }126 }127 }128 @Test129 internal fun batch_connection_issue_before_create(testContext: VertxTestContext) =130 testContext.async(1000) { checkpoint ->131 closeConnection()132 val sut = RedisHeimdallLight(vertx, defaultOptions).markAsTestClient()133 repeat(1000) {134 launch {135 sut.sendBatch().onFailure {136 testContext.verify {137 val cause = it.shouldBeInstanceOf<RedisHeimdallException>()138 cause.reason.shouldBe(CONNECTION_ISSUE)139 }140 checkpoint.flag()141 }.onSuccess { testContext.failNow("Commands on initial connection issue should fail") }142 }143 }144 }145 @Test146 internal fun send_connection_issue_after_some_commands(testContext: VertxTestContext) =147 testContext.async(1000) { checkpoint ->148 val sut = RedisHeimdallLight(vertx, defaultOptions).markAsTestClient()149 coroutineScope {150 repeat(1000) { idx ->151 if (idx == 500) {152 closeConnection()153 }154 launch {155 // Some commands will fail, but all must get executed and if success the result must be156 // in the expected range157 runCatching { sut.sendCmd().await() }158 .onSuccess {159 testContext.verify { it.shouldNotBeNull().toInteger().shouldBeBetween(1, 1000) }160 }161 .onFailure {162 testContext.verify {163 val cause = it.shouldBeInstanceOf<RedisHeimdallException>()164 cause.reason.shouldBeIn(ACCESS_DURING_RECONNECT, CONNECTION_ISSUE)165 }166 }167 checkpoint.flag()168 }169 }170 removeConnectionIssues()171 }172 }173 @Test174 internal fun batch_connection_issue_after_some_commands(testContext: VertxTestContext) =175 testContext.async(1000) { checkpoint ->176 val sut = RedisHeimdallLight(vertx, defaultOptions).markAsTestClient()177 coroutineScope {178 repeat(1000) { idx ->179 if (idx == 500) {180 closeConnection()181 }182 launch {183 // Some commands will fail, but all must get executed and if success the result must be184 // in the expected range185 runCatching { sut.sendBatch().await() }186 .onSuccess {187 testContext.verify {188 it.shouldHaveSize(1).first().shouldNotBeNull().toInteger().shouldBeBetween(1, 1000)189 }190 }191 .onFailure {192 testContext.verify {193 val cause = it.shouldBeInstanceOf<RedisHeimdallException>()194 cause.reason.shouldBeIn(ACCESS_DURING_RECONNECT, CONNECTION_ISSUE)195 }196 }197 checkpoint.flag()198 }199 }200 removeConnectionIssues()201 }202 }203 private fun VertxTestContext.verifyBatchResponse(responseList: List<Response?>, expectedValue: Int) {204 verify { responseList.shouldHaveSize(1).first().shouldNotBeNull().toInteger().shouldBe(expectedValue) }205 }206 private fun VertxTestContext.verifySendResponse(response: Response?, expectedValue: Int) {207 verify { response.shouldNotBeNull().toInteger().shouldBe(expectedValue) }208 }209 private fun RedisHeimdall.sendCmd() =210 send(Request.cmd(Command.INCR).arg("key"))211 private fun RedisHeimdall.sendBatch() =212 batch(listOf(Request.cmd(Command.INCR).arg("key")))213}...

Full Screen

Full Screen

KotestHelpers.kt

Source:KotestHelpers.kt Github

copy

Full Screen

1package io.provenance.scope.loan.test2import com.google.protobuf.InvalidProtocolBufferException3import com.google.protobuf.Timestamp4import com.google.protobuf.util.Timestamps5import io.kotest.matchers.Matcher6import io.kotest.matchers.MatcherResult7import io.kotest.matchers.should8import io.kotest.matchers.shouldBe9import io.kotest.matchers.types.beInstanceOf10import io.kotest.property.Arb11import io.kotest.property.arbitrary.Codepoint12import io.kotest.property.arbitrary.UUIDVersion13import io.kotest.property.arbitrary.alphanumeric14import io.kotest.property.arbitrary.bind15import io.kotest.property.arbitrary.boolean16import io.kotest.property.arbitrary.filter17import io.kotest.property.arbitrary.filterNot18import io.kotest.property.arbitrary.int19import io.kotest.property.arbitrary.list20import io.kotest.property.arbitrary.long21import io.kotest.property.arbitrary.map22import io.kotest.property.arbitrary.pair23import io.kotest.property.arbitrary.set24import io.kotest.property.arbitrary.string25import io.kotest.property.arbitrary.uInt26import io.kotest.property.arbitrary.uuid27import io.provenance.scope.loan.utility.ContractEnforcement28import io.provenance.scope.loan.utility.ContractViolation29import io.provenance.scope.loan.utility.ContractViolationException30import io.provenance.scope.loan.utility.ContractViolationMap31import io.provenance.scope.loan.utility.UnexpectedContractStateException32import tech.figure.servicing.v1beta1.LoanStateOuterClass.LoanStateMetadata33import java.time.Instant34import tech.figure.util.v1beta1.Checksum as FigureTechChecksum35import tech.figure.util.v1beta1.UUID as FigureTechUUID36/**37 * Generators of [Arb]itrary instances.38 */39internal object LoanPackageArbs {40 /* Primitives */41 val anyNonEmptyString: Arb<String> = Arb.string().filter { it.isNotBlank() }42 val anyNonUuidString: Arb<String> = Arb.string().filterNot { it.length == 36 }43 val anyUli: Arb<String> = Arb.string(minSize = 23, maxSize = 45, codepoints = Codepoint.alphanumeric()) // TODO: Is this correct?44 val anyNonUliString: Arb<String> = Arb.string().filterNot { it.length in 23..45 } // TODO: Should be complement of anyUli45 /* Contract requirements */46 val anyContractViolation: Arb<ContractViolation> = Arb.string()47 val anyContractEnforcement: Arb<ContractEnforcement> = Arb.bind(48 Arb.boolean(),49 Arb.string(),50 ) { requirement, violationReport ->51 ContractEnforcement(requirement, violationReport)52 }53 val anyContractViolationMap: Arb<ContractViolationMap> = Arb.bind(54 Arb.list(anyContractViolation),55 Arb.list(Arb.uInt()),56 ) { violationList, countList ->57 violationList.zip(countList).toMap().toMutableMap()58 }59 /* Protobufs */60 val anyValidChecksum: Arb<FigureTechChecksum> = Arb.bind(61 anyNonEmptyString,62 Arb.string(),63 ) { checksumValue, algorithmType ->64 FigureTechChecksum.newBuilder().apply {65 checksum = checksumValue66 algorithm = algorithmType67 }.build()68 }69 val anyUuid: Arb<FigureTechUUID> = Arb.uuid(UUIDVersion.V4).map { arbUuidV4 ->70 FigureTechUUID.newBuilder().apply {71 value = arbUuidV4.toString()72 }.build()73 }74 val anyValidTimestamp: Arb<Timestamp> = anyTimestampComponents.map { (seconds, nanoSeconds) ->75 Timestamp.newBuilder().also { timestampBuilder ->76 timestampBuilder.seconds = seconds77 timestampBuilder.nanos = nanoSeconds78 }.build()79 }80 val anyValidLoanState: Arb<LoanStateMetadata> = Arb.bind(81 anyUuid,82 anyValidChecksum,83 anyValidTimestamp,84 anyNonEmptyString,85 ) { uuid, checksum, effectiveTime, uri ->86 LoanStateMetadata.newBuilder().also { loanStateBuilder ->87 loanStateBuilder.id = uuid88 loanStateBuilder.checksum = checksum89 loanStateBuilder.effectiveTime = effectiveTime90 loanStateBuilder.uri = uri91 }.build()92 }93 fun loanStateSet(size: Int, slippage: Int = 10): Arb<List<LoanStateMetadata>> =94 /** Since we need each *property* to be unique, we must fix the set size & construct the arbs from scratch with primitives */95 Arb.bind(96 Arb.set(gen = Arb.uuid(UUIDVersion.V4), size = size, slippage = slippage).map { it.toList() },97 Arb.set(gen = anyNonEmptyString, size = size, slippage = slippage).map { it.toList() },98 Arb.set(gen = anyNonEmptyString, size = size, slippage = slippage).map { it.toList() },99 Arb.set(gen = anyPastNonEpochTimestampComponents, size = size, slippage = slippage).map { it.toList() },100 ) { randomIds, randomChecksums, randomUris, randomTimestamps ->101 randomIds.indices.map { i ->102 LoanStateMetadata.newBuilder().also { loanStateBuilder ->103 loanStateBuilder.id = FigureTechUUID.newBuilder().also { uuidBuilder ->104 uuidBuilder.value = randomIds[i].toString()105 }.build()106 loanStateBuilder.checksum = FigureTechChecksum.newBuilder().also { checksumBuilder ->107 checksumBuilder.checksum = randomChecksums[i]108 }.build()109 loanStateBuilder.uri = randomUris[i]110 loanStateBuilder.effectiveTime = Timestamp.newBuilder().also { timestampBuilder ->111 timestampBuilder.seconds = randomTimestamps[i].first112 timestampBuilder.nanos = randomTimestamps[i].second113 }.build()114 }.build()115 }116 }117}118private val anyTimestampComponents: Arb<Pair<Long, Int>> = Arb.pair(119 Arb.long(min = Timestamps.MIN_VALUE.seconds, max = Timestamps.MAX_VALUE.seconds),120 Arb.int(min = Timestamps.MIN_VALUE.nanos, max = Timestamps.MAX_VALUE.nanos),121)122private val anyPastNonEpochTimestampComponents: Arb<Pair<Long, Int>> = Instant.now().let { now ->123 Arb.pair(124 Arb.long(min = Timestamps.MIN_VALUE.seconds, max = now.epochSecond),125 Arb.int(min = Timestamps.MIN_VALUE.nanos + 1, max = now.nano),126 )127}128/**129 * Defines a custom [Matcher] to check the violation count value in a [ContractViolationException].130 */131internal fun throwViolationCount(violationCount: UInt) = Matcher<ContractViolationException> { exception ->132 { count: UInt ->133 if (count == 1U) {134 "$count violation"135 } else {136 "$count violations"137 }138 }.let { violationPrinter: (UInt) -> String ->139 return@Matcher MatcherResult(140 exception.overallViolationCount == violationCount,141 {142 "Exception had ${violationPrinter(exception.overallViolationCount)} " +143 "but we expected ${violationPrinter(violationCount)}"144 },145 { "Exception should not have ${violationPrinter(violationCount)}" },146 )147 }148}149/**150 * Wraps the custom matcher [throwViolationCount] following the style outlined in the151 * [Kotest documentation](https://kotest.io/docs/assertions/custom-matchers.html#extension-variants).152 */153internal infix fun ContractViolationException.shouldHaveViolationCount(violationCount: UInt) = apply {154 this should throwViolationCount(violationCount)155}156internal infix fun UnexpectedContractStateException.shouldBeParseFailureFor(classifier: String) = apply {157 this.cause should beInstanceOf<InvalidProtocolBufferException>()158 this.message shouldBe "Could not unpack as class $classifier"159}...

Full Screen

Full Screen

predef-test.kt

Source:predef-test.kt Github

copy

Full Screen

...103}104fun Arb.Companion.throwable(): Arb<Throwable> =105 Arb.string().map(::RuntimeException)106fun <A> Arb.Companion.result(right: Arb<A>): Arb<Result<A>> {107 val failure: Arb<Result<A>> = Arb.throwable().map { e -> Result.failure<A>(e) }108 val success: Arb<Result<A>> = right.map { a -> Result.success(a) }109 return Arb.choice(failure, success)110}111fun <L, R> Arb.Companion.either(left: Arb<L>, right: Arb<R>): Arb<Either<L, R>> {112 val failure: Arb<Either<L, R>> = left.map { l -> l.left() }113 val success: Arb<Either<L, R>> = right.map { r -> r.right() }114 return Arb.choice(failure, success)115}116fun Arb.Companion.intRange(min: Int = Int.MIN_VALUE, max: Int = Int.MAX_VALUE): Arb<IntRange> =117 Arb.bind(Arb.int(min, max), Arb.int(min, max)) { a, b ->118 if (a < b) a..b else b..a119 }120fun Arb.Companion.longRange(min: Long = Long.MIN_VALUE, max: Long = Long.MAX_VALUE): Arb<LongRange> =121 Arb.bind(Arb.long(min, max), Arb.long(min, max)) { a, b ->122 if (a < b) a..b else b..a123 }124fun Arb.Companion.charRange(): Arb<CharRange> =125 Arb.bind(Arb.char(), Arb.char()) { a, b ->126 if (a < b) a..b else b..a127 }128fun <O> Arb.Companion.function(arb: Arb<O>): Arb<() -> O> =...

Full Screen

Full Screen

SubscriptionPostReconnectJobTest.kt

Source:SubscriptionPostReconnectJobTest.kt Github

copy

Full Screen

...26 }27 @Test28 internal fun subscription_after_reconnect_fail(testContext: VertxTestContext) = testContext.async(1) { checkpoint ->29 // given30 val subscriptionFailureCase = Exception("subscription-failure")31 val heimdallConnection = createHeimdallConnection(subscriptionFailureCase)32 val redis = createSuccessfulConnectRedis(heimdallConnection)33 // when & then34 sut.execute(redis).onComplete {35 testContext.verify {36 it.succeeded().shouldBeFalse()37 val subscriptionFailCause = it.cause().shouldBeInstanceOf<java.lang.Exception>()38 subscriptionFailCause.message.shouldBe(subscriptionFailureCase.message)39 }40 checkpoint.flag()41 }42 }43 @Test44 internal fun redis_connect_failed(testContext: VertxTestContext) = testContext.async(1) { checkpoint ->45 // given46 val rootCause = Exception("Test-connect-failure")47 val redis = createFailingConnectRedis(rootCause)48 // when & then49 sut.execute(redis).onComplete {50 testContext.verify {51 it.succeeded().shouldBeFalse()52 val heimdallException = it.cause().shouldBeInstanceOf<java.lang.Exception>()53 heimdallException.message.shouldBe(rootCause.message)54 }55 checkpoint.flag()56 }57 }58 @Test59 internal fun subscription_after_reconnect_successful_even_wrong_connection_type(testContext: VertxTestContext) =60 testContext.async(1) { checkpoint ->...

Full Screen

Full Screen

Tests.kt

Source:Tests.kt Github

copy

Full Screen

...53 }54 test.expectation.success.forEach {55 result.outcomeOf(it) shouldBe TaskOutcome.SUCCESS56 }57 test.expectation.failure.forEach {58 result.outcomeOf(it) shouldBe TaskOutcome.FAILED59 }60 test.expectation.file_exists.forEach {61 with(File("${testFolder.root.absolutePath}/$it")) {62 shouldExist()63 shouldBeAFile()64 }65 }66 }67 }68 }69) {70 companion object {71 val log = LoggerFactory.getLogger(Tests::class.java)...

Full Screen

Full Screen

AsyncGeneratorTest.kt

Source:AsyncGeneratorTest.kt Github

copy

Full Screen

1@file:Suppress("BlockingMethodInNonBlockingContext")2package me.hltj.kthumbor.test3import io.kotest.core.spec.style.StringSpec4import io.kotest.core.test.TestContext5import io.kotest.matchers.should6import io.kotest.matchers.shouldBe7import kotlinx.coroutines.delay8import kotlinx.coroutines.runBlocking9import me.hltj.kthumbor.KthumborResult10import me.hltj.kthumbor.fetchWith11import me.hltj.kthumbor.share.AsyncThumbnailInput12import me.hltj.kthumbor.share.ThumbnailFormat13import me.hltj.kthumbor.share.ThumbnailParameter14import java.awt.image.BufferedImage15import javax.imageio.ImageIO16class AsyncThumbnailInputTest : StringSpec({17 "/oss.png.30x20.jpg" {18 runBlocking {19 with(("/oss.png.30x20.jpg" fetchWith ::staticResourceFetcher)) {20 should {21 it is KthumborResult.Success<AsyncThumbnailInput>22 }23 with((this as KthumborResult.Success<AsyncThumbnailInput>).value) {24 image should { it equalsTo staticResourceImageOf("/oss.png") }25 parameter shouldBe ThumbnailParameter(30, 20)26 format shouldBe ThumbnailFormat("jpeg")27 }28 }29 }30 }31 "/oss.png.0x40.png => BadInput" {32 runBlocking {33 ("/oss.png.0x40.png" fetchWith ::staticResourceFetcher) shouldBe KthumborResult.BadInput34 }35 }36 "BadInput => BadInput" {37 runBlocking {38 ("/text.txt.80x80.png" fetchWith { KthumborResult.BadInput }) shouldBe KthumborResult.BadInput39 }40 }41 "NotFound => NotFound" {42 runBlocking {43 ("no-such-image.80x80.png" fetchWith { KthumborResult.NotFound }) shouldBe KthumborResult.NotFound44 }45 }46 "Failure => Failure" {47 runBlocking {48 with(("/whatever.80x80.png" fetchWith { KthumborResult.Failure(Exception("blah, blah")) })) {49 should {50 it is KthumborResult.Failure51 }52 with((this as KthumborResult.Failure)) {53 exception.message shouldBe "blah, blah"54 }55 }56 }57 }58})59internal suspend fun TestContext.staticResourceFetcher(originPath: String): KthumborResult<BufferedImage> {60 delay(0L)61 return KthumborResult.Success(staticResourceImageOf(originPath))62}63internal fun TestContext.staticResourceImageOf(originPath: String): BufferedImage = ImageIO.read(staticResourceOf(originPath))64internal infix fun BufferedImage.equalsTo(another: BufferedImage): Boolean {65 return if (width != another.width || height != another.height) {66 false67 } else {68 for (x in 0 until width) {69 for (y in 0 until height) {70 if (getRGB(x, y) != another.getRGB(x, y)) {71 return false72 }73 }74 }75 true76 }77}...

Full Screen

Full Screen

uri.kt

Source:uri.kt Github

copy

Full Screen

...11 override fun test(value: Uri): MatcherResult {12 val testResult = match.test(extractValue(value))13 return MatcherResult(14 testResult.passed(),15 { "Invalid Uri $name: ${testResult.failureMessage()}" },16 { "Invalid Uri $name: ${testResult.negatedFailureMessage()}" }17 )18 }19}20infix fun Uri.shouldHavePath(match: Matcher<String?>) = this should havePath(match)21infix fun Uri.shouldNotHavePath(match: Matcher<String?>) = this shouldNot havePath(match)22fun havePath(matcher: Matcher<String?>): Matcher<Uri> = uriHas("path", Uri::path, matcher)23infix fun Uri.shouldHavePath(expected: String?) = this should havePath(expected)24infix fun Uri.shouldNotHavePath(expected: String?) = this shouldNot havePath(expected)25fun havePath(expected: String?): Matcher<Uri> = havePath(be(expected))26infix fun Uri.shouldHavePath(expected: Regex) = this should havePath(expected)27infix fun Uri.shouldNotHavePath(expected: Regex) = this shouldNot havePath(expected)28fun havePath(expected: Regex): Matcher<Uri> = havePath(contain(expected))29infix fun Uri.shouldHaveQuery(expected: String) = this should haveQuery(expected)...

Full Screen

Full Screen

matchers.kt

Source:matchers.kt Github

copy

Full Screen

...8 val actual = ModelNode.Location(value.parent, value.container)9 val expected = ModelNode.Location(null, null)10 return ComparableMatcherResult(11 passed = actual == expected,12 failureMessageFn = { "Node should be released." },13 negatedFailureMessageFn = { "Node should not be released."},14 actual = actual.toString(),15 expected = expected.toString()16 )17 }18}19internal fun beLocatedAt(parent: ModelNode, container: ModelNode.Container<*>) = object : Matcher<ModelNode> {20 override fun test(value: ModelNode): MatcherResult {21 val actual = ModelNode.Location(value.parent, value.container)22 val expected = ModelNode.Location(parent, container)23 return ComparableMatcherResult(24 passed = actual == expected,25 failureMessageFn = { "Node should be located at $expected." },26 negatedFailureMessageFn = { "Node should not be located at $expected." },27 actual = actual.toString(),28 expected = expected.toString()29 )30 }31}...

Full Screen

Full Screen

failure

Using AI Code Generation

copy

Full Screen

1 test("should fail") {2 }3 test("should fail") {4 result shouldNotBe "abc" { "result should not be abc" }5 }6 test("should fail") {7 result shouldNotBe "abc" withClue { "result should not be abc" }8 }9 test("should fail") {10 result shouldNotBe "abc" withClue { "result should not be abc" } { "result should not be abc" }11 }12 test("should fail") {13 result shouldNotBe "abc" withClue { "result should not be abc" } { "result should not be abc" } withCause { IllegalArgumentException() }14 }

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