Object A {
def a = { something}
}
// I've import A, but still have error message: not found: type A
val x = mock[A]
Join Stack Overflow to learn, share knowledge, and build your career.
You may find this email thread instructive.
Whilst pure mocking of the object is not possible with any tool yet, the thread above does have a few options for you. All of which involve changing your design to some degree.
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.
object
, notObject
? applicable updates left to poster) – user166390 Apr 17 '11 at 22:28object A
isA.type
. If you want to define typeA
, you need to e.g. defineclass A { /* as now */ }
and thenobject A extends A
. – Jean-Philippe Pellet Apr 17 '11 at 22:29