2

I am writing unit tests for my spark/scala application. I am using scalamock as well to mock objects, specifically Session / Session Factory.

In one of my test classes, I try to mock the Session. Ex:

val mockedSession = mock[Session]

However, I get this error:

could not find implicit value for evidence parameter of type
org.scalamock.util.Defaultable[org.hibernate.SimpleNaturalldLoadAccess]

I am getting similar errors no matter the object I mock. The format looks correct.

Xavier Guihot
  • 54,987
  • 21
  • 291
  • 190
Kevin Zhou
  • 85
  • 1
  • 6

1 Answers1

0

From the section "Advanced Topics / Raw Types" in the documentation:

"mocking a java method with raw type" should "work" in {
  implicit val d = new Defaultable[java.util.Enumeration[_]] {
    override val default = null
  }
  implicit val d2 = new Defaultable[java.util.Map[_, _]] {
    override val default = null
  }
  
  val mockedRaw = mock[RawTypeInterface]
}

In my case simply importing the offending type resolved the error.

Peewee 733
  • 31
  • 6