Questions tagged [spek]

A Kotlin testing and specification framework for the JVM that allows to easily define specifications in a clear, understandable, human readable way.

48 questions
8
votes
1 answer

java.lang.ClassNotFoundException: com.intellij.junit5.JUnit5IdeaTestRunner using spek in kotlin

I am very new using spek in kotlin testing. When using spek , got the following error on logcat. I don't why I got this java.lang.ClassNotFoundException: com.intellij.junit5.JUnit5IdeaTestRunner at…
Horrorgoogle
  • 7,858
  • 11
  • 48
  • 81
6
votes
1 answer

Testing environment configuration: Android + JUnit 5 + Mockito + Spek + Kotlin

I'm having hard time with configuration of a testing environment based on JUnit Jupiter (5). I have two different errors there: WARNING: TestEngine with ID 'spek' failed to discover…
Michał Klimczak
  • 12,674
  • 8
  • 66
  • 99
5
votes
2 answers

Use JUnit5 Tags for Spek

I am trying to distinguish my tests into Unit- and Integration tests. My idea was to use the new JUnit5 Annotation @Tag("unit") which works nicely for my JUnit tests, but I cannot get it to work with Spek. What I currently have is my class: data…
5
votes
2 answers

Android Studio + Spek integration

I'm trying to add Spek testing framework to my Android Studio project. Following the instructions Here, I ended up adding the following to my module build.gradle: testCompile 'org.jetbrains.spek:spek-api:1.1.5' testCompile…
ElyashivLavi
  • 1,681
  • 3
  • 22
  • 33
4
votes
1 answer

kotlin: how to inherit from Spek class to have common fixture

I want to have a common fixture for my tests: @RunWith(JUnitPlatform::class) abstract class BaseSpek: Spek({ beforeGroup {println("before")} afterGroup {println("after")} }) and now I want to use that spec: class MySpek: BaseSpek({ …
piotrek
  • 13,982
  • 13
  • 79
  • 165
3
votes
1 answer

Kotlin Spek Framework crashes w/ Gradle

I'm getting a crash while spek is trying to find tests. I've tried many different versions and sample configs. I am running from the command line. Gradle 4.0, mac osx. Any help would be appreciated! Here is the error: WARNING: TestEngine with ID…
Patrick Jackson
  • 18,766
  • 22
  • 81
  • 141
2
votes
0 answers

Use Spek with suspend method

I am trying to create a unit test using Spek framework and nhaarman mockito kotlin in my Android Kotlin project. The problem is that when there is nested suspend method I don't know how to mock response.This is how I'm trying I defined: val…
jyodoid
  • 261
  • 2
  • 8
2
votes
1 answer

What is memoized in Spek?

Spek documentation references As a best practice you typically want test values to be unique for each test this can be done by using a lateinit variable and assigning it within a beforeEachTest. lateinit var calculator: Calculator beforeEachTest…
sisternight438
  • 153
  • 1
  • 1
  • 12
2
votes
1 answer

Memoized in spek test give an error: "can not be accessed in this context"

When trying to make a spek test (new thing for us), we get an error while trying to verify the invocations on the mock. The error is: 'm3CustomerService' can not be accessed in this context. java.lang.AssertionError: 'm3CustomerService' can not…
jelmew
  • 543
  • 1
  • 7
  • 15
2
votes
0 answers

Reference Spek Test in Kotlin documentation

I'm working with the kotlin Spek testing framework and want to link to a Spec in my documentation. But when referencing the Spec IntelliJ shows me that it doesn't find the Spec. That's understandable because the Spec is in a test root. But is there…
nikolausk
  • 31
  • 2
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
1 answer

How organize multiple coroutine and expectation blocks in a Kotlin Spek test?

I wrote a failing Spek test because I made an incorrect assumption about execution order involving multiple coroutines and it functions: given("a test") { runBlocking { print("a") } it("block 1") { runBlocking { print("b") } …
Dan Tanner
  • 2,229
  • 2
  • 26
  • 39
2
votes
1 answer

Gradle can't find tests

I'm using Spek testing framework for my Kotlin project. I am able to run tests through Intellij Idea Spek plugin, but can't run them through gradle (build or test). According to SimpleTest.kt when running from Idea plugin 1 test succeeded and 1…
1
vote
0 answers

Use Koin test inside Spek tests

I just want to implement test using koin inside spek test, but just got error No value passed for parameter 'clazz' object HomeViewModelTest : Spek({ private val model by inject() // ← this got error No value passed for…
1
vote
1 answer

RuntimeException Stub! in unit tests using spek

I'm trying to write some unit tests using spek framework, but keep running into RuntimeException (Method threw 'java.lang.RuntimeException exception. Stub!) when trying to access Looper (Looper.getMyLooper()) in code. I'm using the TestScheduler…
Himanshu Chhabra
  • 257
  • 1
  • 2
  • 12
1
2 3 4