3

I'm trying to create automated tests for Android which would emulate Bluetooth communication.

Mockito and DexMaker are working ok but not in this case since good part of the Bluetooth API is consisted of final classes which Mockito can't mock nor spy. That lead me to PowerMock+Mockito combo which should work with private/final/static but AFAIK and saw, it's not Android friendly (not using DexMaker).

Is there any solution for mocking final classes on Android? It would be great if tests could be run on real devices and emulator.

vbokan
  • 133
  • 6

1 Answers1

0

Have you tried PowerMock? You can mock stuff on Android--including final classes.

Vidya
  • 29,932
  • 7
  • 42
  • 70
  • That is one thing I'm trying to avoid since it doesn't run on device. I'm trying to emulate Bluetooth communication using Android framework as much as possible. Doing it the way you suggested probably means I dealing with considerable amount of mocks. I was looking into possibility to run test on device as regular AndroidTest project with PowerMock providing spy for final classes so I could just mock those calls which I need for emulation. That way I could get to as realistic as possible test of communication. – vbokan Dec 25 '13 at 14:29