Questions tagged [kotest]

For questions related to the Kotlin testing framework 'Kotest', which was formerly known as Kotlintest.

Kotest is an open-source testing framework for Kotlin: https://github.com/kotest/kotest/

107 questions
0
votes
1 answer

Exception being thrown and returning status code instead

Regardless of what I do my check for when there is an exception isn't be handled. It's just being thrown in my test. I want to simulate an exception happening during the Db call and to return a 500 status code. Given("given a db exception return…
Yazzz
  • 11
  • 6
0
votes
1 answer

What replaces the now removed Kotest arrow matcher shouldBeSome function variant?

In prior versions of kotest-assertions-arrow, it was possible to write: someOption.shouldBeSome { it.foo shouldBe "x" it.bar shouldBe "y" } I just upgraded to v1.2.1 and this variant has been removed. Only the literal value variant…
Synesso
  • 37,610
  • 35
  • 136
  • 207
0
votes
1 answer

kotest equivalent to usingElementComparatorIgnoringFields from assertJ

assertJ allows you to check for element-wise list equality while ignoring user specified fields like so assertThat(listOfObjects) .usingElementComparatorIgnoringFields("field1", "field2", ...) .containsExactly(object1, object2, ...) I have…
mooglin
  • 500
  • 5
  • 17
0
votes
1 answer

Test Kotlin Coroutines with runBlockingTest{} failed

I have created a simple Micronaut Kotlin Coroutines example want to write tests with kotlin-corotines-test. I have added the kotlin-corotines-test in dependencies. I tried to use runBlockingTest, and the following test(Kotest/FuncSpec)…
Hantsy
  • 8,006
  • 7
  • 64
  • 109
0
votes
1 answer

How to write unit test for the method returns LiveData with Kotest and Mockk library

I am using MVVM to architecutre my android app, my repository has a method which query data from Room Database and returns a LiveData, the signure of my method is: fun getFolder(id: Long): LiveData I want to write a unit test for this…
Jun Du
  • 29
  • 4
0
votes
1 answer

How to mock a bean in a test written in Micronaut Kotest

I am trying to add tests to test Controller, but mock the dependencies. @MicronautTest class PostControllerTest(private val posts: PostRepository, @Client("/") private val client: HttpClient) : StringSpec({ "test get posts endpoint" { …
Hantsy
  • 8,006
  • 7
  • 64
  • 109
0
votes
1 answer

Testing routingfunction with webmvc in springmvc in kotlin

I'm trying to test a routerfunction in webmvc using kotest and mockk. I think the way it's written that only the router function and the test itself should be executed. Everything else is mocked. The routerfunction is configured as…
0
votes
1 answer

Use ThreadLocal Webdriver in kotest for parallel execution

How does one use ThreadLocal Webdriver for parallel browser execution in kotest? Somehow I believe kotlin coroutines messes this up.
Ankit
  • 169
  • 1
  • 4
  • 16
0
votes
0 answers

NoClassDefFoundError thrown during runtime on Kotest Unit Test

I'm getting this NoClassDefFoundError during run time (Run test via Intellij or via gradlew test) Here is my simple test (new to Kotlin and Kotest) class AuthenticationValidatorServiceTest : StringSpec({ val userRepository =…
mengmeng
  • 1,266
  • 2
  • 22
  • 46
0
votes
0 answers

MicronautTest annotation skips test with DescribeSpec

I'm trying to write a test using the @MicronautTest annotation in order to take advantage of the @Requires annotation so that I can run different tests depending on which MICRONAUT_ENVIRONMENTS variable(s) I set. I'm following what I see here:…
Steven Staley
  • 182
  • 1
  • 1
  • 10
0
votes
1 answer

Junit 5 - Is there a way to compare two objects using e.g. assertEquals(a,b) and decide to only show the values which are different in the result

Is there a best practice in comparing two different objects e.g. two Dtos and if they differ to not show a long result where it is difficult to find the property which differs if the object is somehow complex and nested? Currently I see a long…
lennykey
  • 1,195
  • 2
  • 12
  • 25
0
votes
1 answer

Testing in ktor with multiple modules

I'm toying around with a small ktor webapp where I want to split functionality in multiple modules. I have a root module where I install the features I want to use throughout the whole application fun Application.rootModule(testing: Boolean = false)…
0
votes
0 answers

How do I properly Unit Test Spring Boot Reactive app with Kotlin & Kotest

I'm fairly new to Kotlin and Kotest, been scratching my head on how to properly unit test webflux application. Looking over kotest samples here, to me that looks like it's spinning up a WebTestClient server and is more like integration test(please…
Chris
  • 90
  • 10
0
votes
1 answer

Using AbstractProjectConfig in Android project

I am trying to set a global project configuration for Kotest. I have followed the instructions at https://kotest.io/project_config/ However, I have a number of unresolved items in the below: package io.kotest.provided import…
IainCunningham
  • 350
  • 4
  • 13
0
votes
1 answer

kotlin kotest/kotlintest BehaviorSpec afterSpec/finalizeSpec called too often or not at all

I have a kotlin kotest (formerly known as kotlintest) BehaviorSpec with one Given("...") and many When("...") Then("...") under it I want to execute a cleanup after the whole Spec (respectively every Given clause) has finished. @MicronautTest …
Dirk Hoffmann
  • 1,444
  • 17
  • 35