In my Mockito unit test I am trying to mock an array containing instances of the object Message. To do this I try to mock it like normal objects so like:
private var messagesMock = mock(Array<Message>::class.java)
This gives the following error/exception:
org.mockito.exceptions.base.MockitoException:
Cannot mock/spy class [Lrobot.fsrt.robotguest.common.data.Message;
Mockito cannot mock/spy because :
- VM does not not support modification of given type
How to mock an array the right way using Mockito?
Messagea variable, or is it a generic type. Do you want to have ONE array with the object Message within it, or do you want to create some genericArray<Message>instance? So a real minimal reproducible example with additional context would definitely help here.