robfletcher
05/13/2017, 4:48 PMCachingMode.SCOPE
mean nested groups would use the same instance?raniejade
05/13/2017, 4:59 PMraniejade
05/13/2017, 4:59 PMraniejade
05/13/2017, 4:59 PMrobfletcher
05/13/2017, 5:06 PMraniejade
05/13/2017, 5:12 PMjackmiras
05/15/2017, 3:10 PMException in thread "main" java.lang.AbstractMethodError: Method org/jetbrains/spek/engine/Scope$Group.isTest()Z is abstract
exception.jackmiras
05/15/2017, 3:10 PMjk
05/15/2017, 4:59 PMtestRuntime "org.junit.platform:junit-platform-launcher:1.0.0-M4
https://github.com/JetBrains/spek/issues/195#issuecomment-300645464rook
05/15/2017, 6:04 PMonBind
disposables.add(dao.subscribeToVehicle(Consumer { updateView() }))
In writing tests around this object, I’m mocking dao
using Mockito, which then requires me to stub the subscribeToVehicle(consumer: Consumer<Boolean>)
so that it doesn’t return null
. However, when I stub the method call
Mockito.`when`(dao.subscribeToVehicle(any())).thenReturn(mock(Disposable::class.java))
Since any()
returns null
, it fails at runtime with java.lang.IllegalStateException: any() must not be null
. Am I doing something wrong? It feels like this isn’t a problem with Spek or Kotlin, but I’ve scoured all the solutions related to this in Java and tangentially related in Kotlin, but nothing seems to fix my problem.
This link looked like it was a solution to my problem, but the solution isn’t working and the only difference is that I’m using Spek: http://stackoverflow.com/a/30308199/981242
Any help would be greatly appreciated.robfletcher
05/15/2017, 6:09 PMrobfletcher
05/15/2017, 6:09 PMrook
05/15/2017, 6:11 PMrobfletcher
05/15/2017, 6:12 PMrook
05/15/2017, 6:12 PMwfisher
05/15/2017, 8:10 PMrook
05/16/2017, 3:02 PMProcess finished with exit code 0
. My actual test is nested inside that on user clicked ...
group.raniejade
05/17/2017, 4:11 AMrook
05/17/2017, 1:16 PMjackmiras
05/17/2017, 3:46 PMgradle junitPlatformTest
command I'm getting some errors. There is a possibility of this is happening because on terminal the code being tested doesn't run throught Spek plugin that I have installed at IntelliJ IDEA? I'm completely misunderstanting the situation?jackmiras
05/17/2017, 3:49 PMjk
05/17/2017, 5:18 PMjackmiras
05/17/2017, 5:22 PMFailures (1):
Spek:user.UserPresenterTest:given the user presenter:given a get action when data exists in database:it should have a not empty array of users
=> org.mockito.exceptions.misusing.UnfinishedVerificationException:
Missing method call for verify(mock) here:
-> at com.nhaarman.mockito_kotlin.MockitoKt.verify(Mockito.kt:249)
Example of correct verification:
verify(mock).doSomething()
Also, this error might show up because you verify either of: final/private/equals()/hashCode() methods.
Those methods *cannot* be stubbed/verified.
Mocking methods declared on non-public parent classes is not supported.
jk
05/17/2017, 5:41 PMjackmiras
05/17/2017, 5:45 PMobject UserPresenterTest : Spek({
given("the user presenter") {
val request: Request by injector.lazy.instance()
val response: Response by injector.lazy.instance()
val userPresenter: UserPresenter by injector.lazy.instance()
val userFactory: UserFactory by injector.lazy.instance()
given("a get action when data exists in database") {
var users = mutableListOf<User>()
beforeGroup { users = userFactory.create(3) }
afterGroup { userFactory.clear() }
it("should have a not empty array of users") {
userPresenter.get(request, response)
userPresenter.users.isNotEmpty().shouldBeTrue()
}
it("should return a array of users with status 200") {
val answer = userPresenter.get(request, response)
answer shouldEqual Answer(users, 200)
}
}
}
})
jk
05/17/2017, 5:48 PMverify()
error where it appears that there are no mocks - do you have an idea of which line the error message is referring to?jackmiras
05/17/2017, 5:49 PMrequest
and response
objects are mocks but they are being injected by KODEIN.jk
05/17/2017, 5:52 PMverify
with the request/response mocks elsewhere in the tests?jackmiras
05/17/2017, 5:53 PMverify
calls in another files that test other classes but not in this particular UserPresenterTest
filejk
05/17/2017, 5:59 PM