I have a static method in scala and by static method I mean to say that this method is inside an Object named as MyObject. I also have a class named as MyClass where there is a method which calls the method of MyObject internally. I want to write unit test for MyClass and wanted to mock method of MyObject. How can I do this in scala?
class MyClass {
def callMyObject(): String = MyObject.myMethod()
}
object MyObject {
def myMethod(): String = "Original method"
}
I wish when I call callMyObject() of MyClass it should then return a mocked value instead of "Original method"
I am trying mockStatic and spy but no help.