Questions tagged [kotlintest]

KotlinTest is open-source testing framework for Kotlin

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

82 questions
2
votes
0 answers

Generate complete kotlintest report in a Jenkins pipeline?

I am using kotlintest with gradle. When I run my tests in IntelliJ I get to see the whole Given/When/Then structure. This is also reflected in the report I can generate using the IntelliJ Export Test Results function. This works perfectly and does…
Zealot
  • 51
  • 4
2
votes
0 answers

Spring Autowire not initialized with KotlinTest 3.1.8

I know this should be possible, as others have reported it working. However, in a simple 'demo' project (Spring Initializer), I can't get the autowired property to be initialized within the test. When I execute the test in…
James
  • 371
  • 3
  • 10
2
votes
0 answers

Android Studio Default Junit Runner

i'm trying to writing test. I have: Android Studio 3.1.4, Gradle 4.7 io.kotlintest:kotlintest-runner-junit4:3.1.9 When i run my test via green arrow i see: WARNING: TestEngine with ID 'junit-jupiter' failed to discover…
2
votes
1 answer

Ktor: testing REST endpoints using Spek/KotlinTest instad of JUnit Test Class

I have a simple hello world Ktor app: fun Application.testMe() { intercept(ApplicationCallPipeline.Call) { if (call.request.uri == "/") call.respondText("Hello") } } With JUnit test class I can write the test for it, as given in…
o-0
  • 1,713
  • 14
  • 29
2
votes
3 answers

KotlinTest`s BehaviorSpec "No runnable methods" with SpringJUnit4ClassRunner

I wrote the following test: @RunWith(SpringJUnit4ClassRunner::class) class KotlinTest : BehaviorSpec() { init { given("a stack") { val stack = Stack() `when`("an item is pushed") { …
jonathanrz
  • 4,206
  • 6
  • 35
  • 58
2
votes
2 answers

Is it possible to retrieve the string within the lambda expression?

Writing tests using String Spec: class stl : StringSpec() { init { "triangle.stl" { ... } } } Is it possible to retrieve "triangle.stl" within the lambda expression?
elect
  • 6,765
  • 10
  • 53
  • 119
1
vote
1 answer

How to include kotlin.test properly via Maven?

Our team is making first steps into Kotlin and I'm about to to migrate a test. I tried a first example from mockk (https://github.com/mockk/mockk/blob/master/mockk/common/src/test/kotlin/io/mockk/it/InjectMocksTest.kt). For some reason it seems I'm…
Semjon Mössinger
  • 1,798
  • 3
  • 22
  • 32
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

Received a completed event for test with unknown id... Registered test ids...?

I created a brand new project in Android Studio. Here is the software information: Android Studio Arctic Fox | 2020.3.1 Build #AI-203.7717.56.2031.7583922, built on July 26, 2021 Runtime version: 11.0.10+0-b96-7281165 x86_64 VM: OpenJDK 64-Bit…
Coach Roebuck
  • 904
  • 2
  • 12
  • 20
1
vote
0 answers

Kotlin Testing: None of the following functions can be called with the arguments supplied

So I have an error that mentioned in the title. Since I was new to testing I decided to follow a tutorial to test my code. My goal is to see if the there is an item in the list. Here is my code: @Test fun WriteAndReadPlant()=runBlocking(){ …
1
vote
0 answers

Kotlin TestCoroutineDispatcher hangs on cancelAndJoin() after yield()

I have code that is essentially the following: var job: Job? = null fun startJob() = runBlocking(dispatcher) { job = CoroutineScope(dispatcher).launch { myJob() } } suspend fun myJob() { // work block 1 ... yield() // work…
Ken Katagiri
  • 195
  • 1
  • 8
1
vote
0 answers

Wiremock using certificate not working on Windows

This error only happens on the Windows OS. On Linux and MacOS it works fine. I've made sure that the password for the certificates is correct, that they do exist in the mentioned location and that the port is available. Language is Kotlin. Testing…
SasaFajkovic
  • 395
  • 1
  • 4
  • 16
1
vote
0 answers

Create Global DB Schema for Kotlin Test Cases with Exposed Framework

I am new to Kotlin-Exposed Framework. What I am looking for is to have a Global DB schema in H2 Database - jdbc:h2:mem:test for my test cases. In my application, I am using mysql. I want to use H2 only for testing. Below is my code snippet for…
RKP
  • 750
  • 2
  • 12
  • 23
1
vote
1 answer

Unit Testing with Mockk, java.lang.ClassCastException: PhoneValidationKt$isPhoneValid$1 cannot be cast to kotlin.jvm.functions.Function1

Need some help in Unit testing my Kotlin funtion as follows, as i am new to unit testing, i had tried but failed, My Kotlin top level function as follows, package com.reprator.phone //PhoneValidation.kt const val PHONE_LENGTH = 10 fun…
Reprator
  • 2,859
  • 2
  • 32
  • 55
1
vote
2 answers

KotlinTest with Koin: InvocationTargetException

I'm unable to use Koin 2.0.1 with Kotlin-test 3.4.2. I get an InvocationTargetException like this: Running koinexample.KoinSampleTests Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.009 sec <<< FAILURE! - in…
Elifarley
  • 1,310
  • 3
  • 16
  • 23