A Kotlin testing and specification framework for the JVM that allows to easily define specifications in a clear, understandable, human readable way.
Questions tagged [spek]
48 questions
1
vote
0 answers
Spek Unit Test Failing on Bitrise
I have written a unit test, based on Spek Framework, for one of my use cases. Following is the use case code:
class InsertRemoteWidgetUseCase(
private val remoteConfigProviderImplement: RemoteConfigProviderImplement,
private val feedDataStore:…

Harsh Vardhan
- 675
- 1
- 11
- 24
1
vote
1 answer
How to make JUnit 4.0 and Spek Framework 2.0 work together
I have some legacy unit tests written in Groovy and JUnit 4 and I'm working on some new unit tests using Spek framework 2 in Kotlin and Maven. Unfortunately whenever I run the tests I only see the Spek tests, but not the legacy JUnit 4 ones.
I found…

avillagomez
- 443
- 1
- 8
- 18
1
vote
0 answers
WARNING: TestEngine with ID 'spek2' failed to discover tests with Gradle v5.2.1
Having a bit of an issue with using Spek 2 with the Gradle Kotlin DSL. When I right click on my tests folder and hit run all tests I get this error: WARNING: TestEngine with ID 'spek2' failed to discover tests. Am I doing the build script…

Shan
- 541
- 3
- 11
1
vote
1 answer
Run Acceptance tests as a separate Gradle task
I am trying to configure Gradle with Kotlin DSL for my project. It consists of two modules. Module A is a simple Java 11 application. Module B cotains the acceptance tests written in Kotlin using Spek.
I would like to configure gradle so that gradle…

Januson
- 4,533
- 34
- 42
1
vote
1 answer
Spek tests not being run in a maven Java project
I have an existing Java project in which I wish to introduce some Spec tests (in kotlin ofc)
class CalcSpec: Spek({
given("A calculator") {
val calculator = Calculator()
on("Adding 3 and 5") {
val result =…

Xipo
- 1,765
- 1
- 16
- 23
1
vote
1 answer
Run database once per Spek suite
Some tests require running a database, for instance, using Test Containers Library. It obviously takes time to boot it up.
Is there a way to do this only once per entire Spek suite which spans across multiple files? The docs don't say anything about…

kboom
- 2,279
- 3
- 28
- 43
1
vote
2 answers
Spek + Retrofit api test crashing
I'm trying to test Retrofit api with Spek
It throws nullPointerException on the on{...} block
Associated stacktrace : https://pastebin.com/gy6dLtGg
Here’s my test class
@RunWith(JUnitPlatform::class)
class AccountCheckViewModelTest : Spek({
…

silent_control
- 592
- 5
- 10
1
vote
1 answer
Spek - Variable not initialized in test
The following code does not compile:
describe("something") {
context("when something") {
var a: SomeType
beforeEachTest {
a = someNewMutableObject
}
it("should do something") {
…

Dylanthepiguy
- 1,621
- 18
- 47
1
vote
1 answer
How to test sharedpreference that inject in repository in Android MVP Clean Architecture
i've facing a problem to test sharedpreference in datastore. in actual datastore i implement three arguments, those include sharedpreference.
in this case i want to store value, and get that value. mocking not help here.
mocking cannot propagate…

raditya gumay
- 2,951
- 3
- 17
- 24
1
vote
1 answer
Spek access to Internal Visibility Kotlin Classes
I've put together a Maven-based project that uses Spek in the Junit 4 Runner for testing.
I configured the project in Codacy and got a useful suggestion to either document my public classes or reduce their visibility (great).
I've found that the…

Ed Kohlwey
- 468
- 2
- 8
1
vote
1 answer
Groups execution order is wrong in Kotlin Spek
Here is my test:
object MySpek : Spek({
val myMock1: MyMock1 = mock()
val myMock2: MyMock2 = mock()
val handler = StartModeHandler(myMock1, myMock2)
val session = mock {
on { user…

Saandji
- 428
- 4
- 9
1
vote
0 answers
JaCoCo Gradle plugin reports 0.0 class covered ratio for each package
My directory structure is:
|/src
| |/main
| | |/com.episo
| | | |/contracts
| | | | |/clip
| | | | |/security
| | | |/repositories
| | | | |/memory
| |/test
| | |/com.episo
| | | |/contracts
| | | | |/clip
|…

Mat Jones
- 936
- 1
- 10
- 27
1
vote
1 answer
Running tests with kotlin spek and kluent
Trying to get spek working with kotlin but running into some problems. I have the simplest test:
object TestSpec : Spek({
describe("A greeter") {
it("should fail") {
"hello" shouldEqual "somethingelse"
}
…

Geert Olaerts
- 1,155
- 2
- 9
- 17
0
votes
0 answers
Mock Retrofit 2 call.execute() - call = org.mockito.exceptions.misusing.UnfinishedStubbingException
I write unit tests for my use cases. Many of them make network requests by calling methods of the interface, which returns them the Call object of the Retrofit library (it delegates the execution of the request to a higher level, since the use cases…

Sunbey13
- 339
- 4
- 12
0
votes
0 answers
How to make Junit platform test fail if test discovery fails for some classes?
I have a Gradle build using JUnit 5 to run Spek tests.
Some of the tests fail during setup:
Feb 17, 2020 4:38:42 PM org.junit.platform.launcher.core.DefaultLauncher handleThrowable
WARNING: TestEngine with ID 'spek' failed to discover…

Midiparse
- 4,701
- 7
- 28
- 48