How to mock a final class with mockito

后端 未结 25 1450
日久生厌
日久生厌 2020-11-22 16:35

I have a final class, something like this:

public final class RainOnTrees{

   public void startRain(){

        // some code here
   }
}

I

25条回答
  •  旧巷少年郎
    2020-11-22 16:49

    Mocking final classes is not supported for mockito-android as per this GitHub issue. You should use Mockk instead for this.

    For both unit test and ui test, you can use Mockk with no problem.

提交回复
热议问题