Subscribed unsubscribe Subscribe Subscribe

Augmented Usamimi

it { is_expected.to be_blog.written_by(izumin5210) }

AndroidでBLEが絡むコードのテストを書きたい

BluetoothGattがfinalなのでモック化出来ない. PowerMockで誤魔化そうかと思ったけど,DexmakerMockitoAndroidで利用するためのやつ?)と相性が悪いのかテストが走らなくなる.

stackoverflow.com

MockMaker is a glue module that integrates dexmaker with Mockito. It does what's necessary for Mockito to generate concrete classes with Dalvik .dex files instead of JVM .class files.

It's possible that Powermock will work with Dexmaker, but it's unlikely advanced Powermock features will work. In particular, Powermock advertises this:

PowerMock uses a custom classloader and bytecode manipulation to enable mocking of static methods, constructors, final classes and methods, private methods, removal of static initializers and more. That custom class loader is unlikely to work on dalvikvm.

これがキッチリした言語におけるテスティングの面倒くささか〜 という印象.

Testing Support Library使ってテスト書いてるんだけど,Robolectricに変えたほうがいいのかな.