Reputation: 4017
I have the following class:
object CharacterDAO : GenericDAO<Character>(Character::class.java, "id") {
}
That I would like to mock using Mockito/PowerMockito. Any suggestions?
Upvotes: 1
Views: 1497
Reputation: 7153
Not using Mockito/PowerMockito, but there's a new library called Mockk that allows you to do exactly that:
From it's documentation:
object MockObj {
fun add(a: Int, b: Int) = a + b
}
objectMockk(MockObj).use {
assertEquals(3, MockObj.add(1, 2))
every { MockObj.add(1, 2) } returns 55
assertEquals(55, MockObj.add(1, 2))
}
Upvotes: 0