LoginSignup
8
2

More than 5 years have passed since last update.

mockito-kotlinのfinal class エラーの対処

Posted at
org.mockito.exceptions.base.MockitoException:
Cannot mock/spy class com.example.data.model.WeatherData
Mockito cannot mock/spy because :
– final class

このエラーは英語の通りfinal classをkotlinはデフォルトで作ってしまうためダメと言われてます

そのため、既存のプロジェクトにて

vi app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
org.mockito.plugins.MockMaker
mock-maker-inline

これで動くようになります

8
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
2