Object A {
def a = { something}
}
// I've import A, but still have error message: not found: type A
val x = mock[A]
You don't. Not only A
is not a type or class -- it is an instance -- but it is an instance of a singleton (A.type
).
What you do instead is put your methods on a trait
, and make the object extend it. Then, you mock the trait instead of mocking the object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With