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
1
vote
1 answer

How to avoid initializationError in kotest with SpringBootTest?

I have a simple JUnit "smoke" test which check if Spring context is loaded correctly: @SpringBootTest class ContextLoadJUnit { @Test fun contextLoads() { //empty by design } } I'm trying to rewrite it into kotest. I've tested…
Piotr Pradzynski
  • 4,190
  • 5
  • 23
  • 43
1
vote
1 answer

Kotest: Execution Order of (Nested) Lifecycle Hooks

I'm confused about the order in which lifecycle hook in Kotest are executed, especially when it comes to nested tests. Consider the following example: import io.kotest.core.spec.style.DescribeSpec class KotestTest : DescribeSpec({ beforeSpec {…
1
vote
1 answer

Test Suite in kotest

I don't know if I am missing something but I could not find anything that says how to do a test suite like in JUnit. Can someone help me? I saw that documentation offers grouping tests, but when I run from Gradle, the logs are really large, and not…
1
vote
0 answers

How can I run Nested Test in kotest?

I'm trying to migrate test framework from JUnit 5 to kotest. I selected Annotation Spec at first (to check compatibility), but Nested Annotation doesn't work as expected Sample code is below class Outside : AnnotationSpec() { @Test fun…
cjlee
  • 378
  • 3
  • 10
1
vote
1 answer

How to set a project wide configuration for iterations in property tests in kotest?

I'd like to limit the default number of iterations for Property Based Tests in Kotest, preferably in the code (instead of using the also existing system property kotest.proptest.default.iteration.count inside my gradle/maven project). The Global…
Chris
  • 408
  • 2
  • 10
1
vote
1 answer

Kotlin and kotest with arbitrary values: what am I doing wrong?

I've gone through the kotest documentation and am trying to incorporate some property based testing into my code. From the documentation, my impression was that if you use a forAll, if kotest has a built-in Arb, it would generate arbitrary…
Sebastian
  • 715
  • 6
  • 13
1
vote
1 answer

Tests failing when using ClientInterceptor to add headers to the stub

In the following code MetadataUtils.attachHeaders is deprecated (I'm using grpc 1.45.1): "request without bearer token should fail" { val channel: ManagedChannel = ManagedChannelBuilder.forAddress(address, port) …
Pawel
  • 466
  • 1
  • 7
  • 20
1
vote
0 answers

Kotest with Fiddler

I am trying to rewrite our automatic tests to Kotest. Previously we were using plain AndroidInstrumentation tests running on a device. The tests rewritten to Kotest do work well, however I am not able to force them to use Fiddler running on the same…
Mapar
  • 61
  • 4
1
vote
0 answers

In kotest is there a way to have a "before" hook run once for a TestContainer it's in?

I'm trying to use Kotest to write nested tests that have hooks that only run once per nest level. This is how mocha works in JavaScript and how RSpec works in ruby. In mocha the function is called before. I tried using beforeContainer but it runs…
Bryan
  • 21
  • 3
1
vote
0 answers

Kotest nested tests & Mockk in Spring WebMvcTest randomly failing with MockKException: no answer found

I've tried searching anything similar and tried various solutions to no avail. I have some nested tests which are failing with MockKException: no answer found, even though threads should not be touching mocks under use in another test, as I've…
OsaSoft
  • 589
  • 5
  • 19
1
vote
1 answer

idea: set default test (runner) configuration?

Idea offers different (test run) configurations, e.g. with the runners Gradle, JUnit and Kotest: How do I set the default runner, e.g. to Kotest, which is created when I click on Run myTest? Currently, my maven project by default creates Kotest…
Stefan K.
  • 7,701
  • 6
  • 52
  • 64
1
vote
0 answers

Kotest Unit test implementation in Android Studio

I'm new at unit tests, and i'm developing a Kotlin project, so i thought that it would be great to use a Kotlin based framework. I've been having problems when adding dependencies to my project. Does anyone now if Kotest can be used in Gradle <6??…
1
vote
1 answer

kotest: automatically derive Generator from data class

I wonder if it's possible to automatically derive a Generator from a data class like e.g. scalacheck-shapeless?
Stefan K.
  • 7,701
  • 6
  • 52
  • 64
1
vote
0 answers

Is it possible to spy on an object in which I have no control over it's creation, using mockk?

I have a Kotlin project using kotest as my unit testing framework and mockk to take care of my mocking requirements. I am new to all aspects of the Kotlin language and chosen testing libraries/frameworks. I have a simple class in which a function…
1
vote
1 answer

How to create reusable steps in BehaviorSpec

I am still new to Kotlin and Kotest and I am struggling of finding a way to create a BDD style of test. My problem is how the framework enables to create reusable Given step. For example: class KotestTest1 : BehaviorSpec({ given("State A") { …
Juhan
  • 11
  • 1