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
2
votes
1 answer

Kotest setup issue, 'unresolved reference'

I am trying to add kotest to my library, but am just getting: e: /home/brett/git/ttnt/src/test/kotlin/io/bmb/ttnt/lib/SqliteManagerTest.kt: (3, 18): Unresolved reference: specs e:…
Brett
  • 113
  • 3
  • 9
2
votes
2 answers

kotest nested spec in describe clause

I've started using kotest:4.0.5 (kotlintest) and having problem with stringSpec function nested in describe clause. Example: class SellerTest : DescribeSpec({ describe("Registration") { context("Not existing user") { …
MrNetroful
  • 497
  • 8
  • 28
2
votes
1 answer

Does Kotest (previously KotlinTest) still work in Android Studio?

As far as I can tell, Kotest requires JUnit 5: https://github.com/kotest/kotest/issues/1104 It also requires Gradle 6: https://github.com/kotest/kotest/issues/1301 I presume it's possible to get this all set up and working, but isn't it true that…
Tom B
  • 115
  • 8
2
votes
2 answers

How to run a single test in a context using kotest/kotlintest

I have the following test suite: class FooTest : FunSpec() { init { context("a context") { test("first test") { true shouldBe false } test("f:second test") { true…
u.sanyo
  • 47
  • 1
  • 7
2
votes
1 answer

Kotest parallelism with Mockk

So I've been using kotest in combination with mockk, but I encountered an issue when switching from single thread mode to multiple by adding this to ProjectConfig class: override fun parallelism(): Int =…
SMGhost
  • 3,867
  • 6
  • 38
  • 68
1
vote
0 answers

How to use kotest ExpectSpec in Android?

I want to use kotest ExpectSpec in Android. But I don't know how to setup Junit5 runner. This is my app-level build.gradle file ... android.testOptions { unitTests.all { it.useJUnitPlatform() } } dependencies { ... …
Doo Rim
  • 11
  • 1
1
vote
1 answer

How create parameterized tests with kotest and AnnotationSpec style

How to use data driven in Kotest with style AnnotationSpec() Example for JUnit 5: @ParameterizedTest @ValueSource(ints = {1, 3, 5, -3, 15, Integer.MAX_VALUE}) // six numbers void isOdd_ShouldReturnTrueForOddNumbers(int number) { …
GLOCTARR
  • 13
  • 3
1
vote
0 answers

How to compare map and object using kotest?

There is a class: data class A( var id: Long = 0, var date: String? = null, var age: Long, var sex: String? = null, var city: String? = null ) Object: val obj = A(id = 5, age = 22, sex = "male", city = "Example city") There is a…
lomdok
  • 21
  • 2
1
vote
0 answers

How does kotest and maven parallelism work?

Does kotest run tests in parallel if maven is running on multiple threads like mvn -T 3? If maven is on -T 1, then how does parallelism work in kotest?
Nayan Seth
  • 73
  • 1
  • 7
1
vote
2 answers

How to write a test to assert on a thrown exception in Kotest?

I want to cover a case via test when exception is thrown. I've tried passing an incorrect input but still no luck. In Kotest - can we explicitly throw exception when a function is called? I couldn't find any documentation in Kotest Doc to cover this…
rahul.cs
  • 45
  • 6
1
vote
1 answer

Kotlin & MockK - mocking not working if a mocked method is called from another method

I have a problem with MockK. I have a class: @Service class ItemServiceImpl(private val varPuObjectMapper: VarPuObjectMapper) : OutboundAdvicesService { override suspend fun getItemsForWarehouse(warehouseId: String): ItemsDTO { // do…
hc0re
  • 1,806
  • 2
  • 26
  • 61
1
vote
1 answer

Kotest: disable test with reason in FreeSpec

I'm trying to convert some tests that was previously written in Junit to kotest. I need to use the FreeSpec style. However, i cannot find a good way (not in the documentation and not after trying for several hours) to disable a test and state a…
Liran_k
  • 21
  • 2
1
vote
1 answer

Testing a Kotest test

I am not sure if this is possible or if there's a better architecture for this. I wrote a function that does some tests: fun validate(a: Any?, b: Any?){ a shouldBe b } My function is obviously more complex than that, but now I would like to test…
buzoherbert
  • 1,537
  • 1
  • 12
  • 34
1
vote
2 answers

How to run kotest which are not tagged by default?

In the kotest framework, there is a way to group tests with custom tags and you can run the particular group by selecting via Gradle parameter like gradle test -Dkotest.tags="TestGroupOne" I have two test cases one is with a tag and another one is…
Vencat
  • 1,272
  • 11
  • 36
1
vote
1 answer

Mockk verify wasNot called failed

I have a question regarding mockk. When using MockK's wasNot called to check that ClassA is called, there is a problem that the test fails if it is called in another test even if ClassA is not called in the current test. Why is this happening and…
eleven22
  • 83
  • 2
  • 7