'can we mock method inside object

object Abc {
    method1(param1,param2):Future[Option[String]] = {
        //some work
    }
}

We are using method1 somewhere and need to stub method1 how can we do this in scala using mockito

I am doing like this :

when(method1(mockParam1, mockParam2)).thenReturn(SomeExpectedStuff)

but facing NPE .



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source