ユニットアンドロイドSensorEvent
とMotionEvent
クラスをどのようにユニットテストするのですか?ユニットテストのためのMotionEventとSensorEventをアンドロイドでモックする方法は?
ユニットテスト用にMotionEvent
オブジェクトを1つ作成する必要があります。私はAndroidのメーカーに取得しています
MotionEvent Motionevent = Mockito.mock(MotionEvent.class);
しかし、次のエラー:MotionEventクラスの
(私たちはMotionEvent
カスタムオブジェクトを作成するために、私たちが嘲笑した後に使用することができますMotionEvent
ためobtain
方法を持っている)、私のようなMockito
で試してみました:
java.lang.RuntimeException:
Method obtain in android.view.MotionEvent not mocked. See https://sites.google.com/a/android.com/tools/tech-docs/unit-testing-support for details.
at android.view.MotionEvent.obtain(MotionEvent.java)
このエラーに言及したサイトに続いて、私は
012を追加しましたon build.gradleでも、この同じエラーが発生しています。これについてのアイデア?
SensorEventの場合、例:https://medium.com/@jasonhite/testing-on-android-sensor-events-5757bd61e9b0#.nx5mgk6sq – Kikiwa