In my past post a number of months ago, I went over the basics of automating your android testing environment. In this post, I want to expand on that even further.
The scripts I had outlined previously only made use of usb connected devices. So in essence, every device you want to test on had to be plugged into your computer before you could run the tests and gather results.
Unfortunately that isn’t very scalable. If you work in a large office with a multitude of android devices, testing in this way is pretty difficult.
However, ADB has an option to connect to your devices over your WiFi network. If we connect our devices to adb over wifi, we can unplug them and run our tests without having to connect every device to our computer.
What we’ll need
- Wifi network
- Android devices
- All devices connected to this wifi network
Unfortunately, unless your device is rooted, we’ll have to connect our device through USB then initiate our ADB tcp connection. Then we can remove from USB and still be connected to our main computer.
I’ve added a script that will handle and store all device connections.
The Gist
The script calls adb to fetch your connected devices. If your devices aren’t connected over wifi, it will fetch your device’s network ip and connect ADB to that ip.
Once connected, it will save all connections into a text file. This script requires a config file called test_config.
Inside are some basic environment vars:
The ones of importance for this script are device_ip_file and port. Port represents the default port number you will connect to your device’s ip over (e.g. 127.0.0.1:5555). The port number increases per connection.
Imagine your network of connected devices:
- 127.0.0.1:5555 -> will connect to the ADB on port 5555
- 127.0.0.2:5556 -> will connect to ADB on port 5556
… and so on for each device.
$device_ip_file is the location of the file you will write connected devices’ ip:port combination to.
So to setup for wifi ADB connections, plug in your device(s) and run
You can do this as many times as you want and the devices will remain connected, until you explicitly disconnect them, lose network connection or restart the ADB instance.
From there, just run your test_automator.sh script from the previous post, and you’re all set!