I have an object that contain a private method(mylog), when I want to mock a method(myMethod) that call the private method it throw me an exception
Caused by: java.lang.NullPointerException
Here my code :
object myObject {
private val mylog = new Logger("Title")
def myMethod(parameter1: Int): Int = {
mylog.info("I log a message here")
parameter1
}
}
Here my mock method
withObjectMocked[myObject.type] {
when(myObject.myMethod(ArgumentMatchers.any()).thenCallRealMethod()
[...]
}