Answer the question
In order to leave comments, you need to log in
Why does the default implementation of the stub method fire?
Let's say there is a class A, with a method doSomething(arg:Int):Boolean, which returns a Boolean and can throw an exception. I don’t give its code because it’s a fictional example.
I want to make a stub of this method. I do it in the following way.
class ATest{
@Test
fun `test method`(){
val a = mock(A::class.java)
val param = 5
`when`(a.doSomething(param)).thenReturn(false)
assertFalse(a.doSomething(param))
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question