Using gradle to test Android applications in emulator

Ok, I want to use gradle to run my tests in an emulator.

gradle has two goals that let me run tests:

  • connectedCheck
  • deviceCheck

If I understand correctly, we should use deviceCheck to test files in the emulator, but when it starts, it does not run any tests.

connectedCheck also does not work because it cannot find the device (emulators do not appear in Android Studio, like my mobile phone).

I would like (ideally):

  • run my gradle script
  • he loads the emulator
  • he runs tests on this emulator
  • he turns off the emulator

I would also like to have a goal that will not load or reject the emulator, but it will use one if it gets up.

Can any of this be done? I cannot find documentation anywhere on how to configure gradle android plugin.

+7
android android-emulator android-gradle gradle
source share
1 answer

The emulated device is a connected device. I cannot say that gradle has a way to run the emulator for you, other than the Exec task. I leave a couple of emulators always running in the background with -no-window, and on our CI I did a little bash script to run several at different API levels before calling gradle, and then close them down after.

I came here to find an example of using DeviceCheck. It seems like it should be taken for granted.

+5
source share

All Articles