Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using gradle to test android apps in an emulator

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

gradle has two targets that allow me to run tests:

  • connectedCheck
  • deviceCheck

If I understood correctly, we should use deviceCheck to test stuff in an emulator, but when I run it runs no tests.

connectedCheck also doesn't work because it can't find a device (emulators don't appear in the Android Studio the way my cell phone do).

What I would like is (ideally):

  1. run my gradle script
  2. it boots up an emulator
  3. it runs tests on that emulator
  4. it turns down the emulator

I would also like to have a target that won't boot or turn down the emulator, but it will use one if one is up.

It's possible to do any of these things? I can't find documentation anywhere on how to configure gradle android plugin.

like image 202
Rafael Avatar asked Aug 15 '14 17:08

Rafael


1 Answers

An emulated device is a connected device. I can't tell that gradle has a way of starting an emulator for you short of an Exec task. I leave a couple emulators always running in the background with -no-window, and on our CI I did up a little bash script to fire up a few at various API levels before gradle is invoked and then shut them down afterward.

I came here searching for an example of how deviceCheck is used. It seems like it's supposed to be self-evident.

like image 121
MithrilTuxedo Avatar answered Oct 30 '22 13:10

MithrilTuxedo