https://kotlinlang.org logo
#mockk
Title
# mockk
s

Sergio Crespo Toubes

05/20/2019, 3:08 PM
how can i mockk bitmap?
l

LeoColman

05/20/2019, 3:08 PM
What do you mean?
s

Sergio Crespo Toubes

05/20/2019, 3:09 PM
val bitmap = mockk<Bitmap>
something like that
or init
l

LeoColman

05/20/2019, 3:09 PM
Mockk is used to simulate functionality of a class, I don't think one can mock an image
As in create a simulated image
Could you give us some more of the code you're using as example?
s

Sergio Crespo Toubes

05/20/2019, 3:10 PM
ok... the problem is that with groovy i could do this
new Bitmap()
and i cant do that with kotlin, then i tried mockk it
l

LeoColman

05/20/2019, 3:17 PM
why can't you do that in kotlin?
If you can do it in groovy, you probably can in kotlin
s

Sergio Crespo Toubes

05/20/2019, 3:18 PM
it's showing me this error
Cannot access '<init>': it is public/*package*/ in 'Bitmap'
then i use createBitmap but it crash while testing
Method createBitmap in android.graphics.Bitmap not mocked
l

LeoColman

05/20/2019, 3:30 PM
Perhaps you can mock it, then?
s

Sergio Crespo Toubes

05/20/2019, 3:39 PM
it works now. Sorry Leonarod, dunno how i called it before :S
it crashed
l

LeoColman

05/20/2019, 3:40 PM
You can mock the method, I mean
s

Sergio Crespo Toubes

05/20/2019, 3:40 PM
yes
but i could do this
val bitmap = mockk<Bitmap>()
my mistake. Sorry
idk how i declared it before
281 Views