I have a class. It has a companion object A with a factory method.
class A private[somepackage](x: Int) {
}
object A { def createA(y: Int): A = { new A(y) } }
Now I need to create the mock object of A in a scalatest file which is in a different package.
When I give
private val a = mock[A] --> I get compilation error.
constructor A in class A cannot be accessed in <<somewhere>>.
Is there a better way to mock the object ??
                        
Consider using a proxy to access class A, and stub/mock that proxy class instead. E.g., if
A.doStuffis what you want to mock/stub, andA.accessStuffis what you need in your code, create a classReplace usage of
A.createAwith newADecorated(A.createA()).ADecoratedis what you work with now