kevin.cianfarini
11/28/2018, 7:11 PMthis.walk()
?ursus
11/30/2018, 2:22 PMvkholyavin
12/11/2018, 9:23 AMval myFunction = mock<(String) -> Unit>()
// actions
verify(myFunction).invoke(captor.capture())
throws: java.lang.IllegalStateException: captor.capture() must not be nullcesards
12/12/2018, 8:52 PMkluent
and mockito kotlin
and apparently mockito kotlin buid hasn’t been updated for a while so it was exposing apis that shouldn’t be exposed:
https://github.com/nhaarman/mockito-kotlin/blob/2.x/mockito-kotlin/build.gradle#L35Dhanapal
01/02/2019, 7:10 AMval
in test case other than reflection. I don't want this variable gets modified in main package.
Appreciate you help.Smorg
01/04/2019, 7:25 AMmockito-kotlin
in my project, and I saw from the docs that I can assign a property to a mock without actually having to use stubs. But this does not seem to be working in my code.
@Test
fun testCase() {
val entity = mock<Entity>()
entity.property = Property()
assert(entity.property != null) // fails
}
Or does it only work with primitive types or interfaces?matt tighe
01/10/2019, 1:00 AM@Test
fun `Submits app selection if selections can be made`() {
mainActivityViewModel.submitAppSelection(selectedApp)
runBlocking {
verify(mockAppsStartupFsm).submitEvent(AppSelected(selectedApp))
}
}
class MainActivityViewModel {
fun submitAppSelection(app: App) {
if (!selectionsCanBeMade()) return
lastSelectedApp = app
val coroutineScope = CoroutineScope(Dispatchers.Default)
coroutineScope.launch { appsStartupFsm.submitEvent(AppSelected(app)) }
}
}
AppsStartupFsm#submitEvent
is a suspending function.
Changing the runBlocking scope to be function level doesn’t seem to help. Is there something I’m missing with verification of suspending functions?bjonnh
01/21/2019, 2:44 AMEugen Martynov
01/28/2019, 9:57 AMTalon
01/30/2019, 8:15 PMval commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.9.1")
}
}
I'm getting Unresolved reference: Test
when I try and gradle check
this multiplatform project. IntelliJ is able to find test-annotations-common
at least enough to auto-import and stuff but something about the tests loses it?tddmonkey
02/14/2019, 5:11 PMdmcg
02/15/2019, 1:33 PMBen
02/22/2019, 6:16 AMpablisco
03/12/2019, 11:41 AMSam
03/17/2019, 4:18 PMhenrik
03/28/2019, 5:26 AMAdalPari
04/30/2019, 6:24 PMLawik
05/01/2019, 8:10 AMMockk
I am trying to mock the following function fun <T> openAndCloseSession(handler: (Session) -> T): T {
val session = HibernateUtil.sessionFactory.openSession()
val res = handler(session)
if (session.isOpen) {
session.close()
} else {
println("[WARNING]: session closed by handler function: ${handler::class.java.enclosingMethod}, please consider omitting manually closing the session in the handler as it will be closed automatically at the end of the call")
}
return res
}
I want the mock to just call the provided handler
(which I have mocked too). This is where I am currently at val session: Session = mockk()
every { openAndCloseSession<Any>(any()) } answers {firstArg<(Session) -> Any>().invoke(session)}
Sadly this doesn't work.reik.schatz
05/06/2019, 11:00 AMassertNotNull
or assertThat(nullable).isNotNull
won’t do the tricknhaarman
05/24/2019, 8:16 PMsavePeriodicDump
is non-final: any()
returns null
. If the savePeriodicDump
method is final its code will be executed, meaning a null
check will be performed on the parametersamneirinck
06/07/2019, 11:28 AMMatej Drobnič
06/10/2019, 5:42 AMMika Y Kost
06/11/2019, 7:11 AMsvenjacobs
06/12/2019, 8:56 AMactual shouldEqual expected
. Currently I'm using Kluent but it just outputs the toString()
values of both classes. If I want to find out which value(s) are actually different I have to do it manually.Anthony f
06/13/2019, 1:35 PMRainer Schlonvoigt
06/20/2019, 12:32 PMkotlin-test-junit
?Badecx
06/24/2019, 10:32 PMmockk
and I have an every
call that returns a list but I’m getting an error o.mockk.MockKException: Bad recording sequence. Please finalize every { ... } block with returns/answers/just Runs
, I changed to answers {}
and it worked perfectly and I don’t know why. Does anyone have ever go through this issue?tylerwilson
06/26/2019, 9:59 PMJoan Colmenero
07/04/2019, 1:44 PMattachView
and detachView
on my Presenter do I have to test these methods? Inside of the presenter I have the loadData
and I have the unit tests for this loadData
but then I have these methods and I don't know if I have to unit test those or not
And then I have a repository that does this
class CryptoListRepositoryImpl(var cryptoCurrencyService: CryptoCurrencyService) : CryptoListRepository {
override fun getResultData(): Single<CryptoResponse> {
return cryptoCurrencyService.getCryptoCurrency()
}
}
do I have to unit test this getResultData()
? (edited)
And then an use case
class GetCryptoListUseCase @Inject constructor(var cryptoListRepository: CryptoListRepository) {
fun execute(): Single<List<CryptoViewModel>> {
return cryptoListRepository.getResultData().map {
cryptoCurrencyMapper(
it
)
}
}
}
I have to Unit test the mapper
and the use case execute()
?Manuel Lorenzo
07/18/2019, 12:00 PMtestDevelopDebugUnitTest
gradle task, I started to get random errors such as
Missing method call for verify(mock) here:
-> at com.nhaarman.mockitokotlin2.VerificationKt.verify(Verification.kt:72)
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.
this only happen when the gradle task is executed, and if I ignore that test, then another one fails 🤔 I didn’t modify anything there, not in the injection or anything related.I tried changing the mockito-kotlin version, the mockito-core version, upgrading gradle, upgrading the gradle android plugin..Manuel Lorenzo
07/18/2019, 12:00 PMtestDevelopDebugUnitTest
gradle task, I started to get random errors such as
Missing method call for verify(mock) here:
-> at com.nhaarman.mockitokotlin2.VerificationKt.verify(Verification.kt:72)
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.
this only happen when the gradle task is executed, and if I ignore that test, then another one fails 🤔 I didn’t modify anything there, not in the injection or anything related.I tried changing the mockito-kotlin version, the mockito-core version, upgrading gradle, upgrading the gradle android plugin..tddmonkey
07/18/2019, 12:02 PMManuel Lorenzo
07/18/2019, 12:04 PMtddmonkey
07/18/2019, 12:05 PMManuel Lorenzo
07/18/2019, 12:07 PMorg.gradle.jvmargs=-Xmx4608M
android.enableD8=true
android.useAndroidX=true
android.enableJetifier=true
org.gradle.parallel=false
kotlin.parallel.tasks.in.project=true
kapt.use.worker.api=true
android.enableUnitTestBinaryResources=true
kapt.incremental.apt=true
org.gradle.parallel=false
but still failingtddmonkey
07/18/2019, 12:36 PMManuel Lorenzo
07/18/2019, 12:43 PM