In my project I tried to setup a test in which should be verified that a method is called with a specific parameter. For this I am using Mockito and Kotlin.
In the test I am using a mock class. (publisher
) This class is part of rosjava and contains a method publish
;
public interface Publisher<T> extends TopicParticipant { //(java)
void setLatchMode(boolean var1);
boolean getLatchMode();
T newMessage();
void publish(T var1);
boolean hasSubscribers();
int getNumberOfSubscribers();
void shutdown(long var1, TimeUnit var3);
void shutdown();
void addListener(PublisherListener<T> var1);
}
When I try to set my expectation like:
val publisherMock = mock(Publisher::class.java)
verify(publisherMock, atLeastOnce()).publish(message) // message is underlined with a red color
This does not compile and says that the parameter for publish
should be of class Nothing!
. Why is this?