Field Testing Using ADB Commands Notes By ShariqSP
Field Testing Using ADB Commands
1. Setting Up for Field Testing
Field testing involves testing an app or device under real-world conditions such as different network environments, locations, and user scenarios. ADB commands provide a powerful way to simulate and monitor field conditions.
- Ensure ADB is installed and configured correctly.
- Connect your device to your computer and verify the connection:
adb devices
- Enable USB Debugging on your device:
- Navigate to Settings > Developer Options and enable USB Debugging.
2. Simulating Network Conditions
Field testing often involves testing under different network conditions. ADB allows you to simulate these scenarios:
- Monitor Current Network State:
adb shell dumpsys connectivity
- This displays details about the current network status, including the connected type (Wi-Fi, LTE, etc.).
- Simulate Airplane Mode:
adb shell settings put global airplane_mode_on 1
- This turns on airplane mode. To turn it off, replace
1
with0
.
- This turns on airplane mode. To turn it off, replace
- Simulate No Network:
adb shell svc data disable
- This disables mobile data. To enable it again, use:
adb shell svc data enable
- This disables mobile data. To enable it again, use:
- Simulate Switching Networks:
adb shell am start -n com.android.settings/.Settings\$DataUsageSummaryActivity
- This opens network settings for manual changes.
- Simulate Network Throttling:
adb shell "tc qdisc add dev wlan0 root netem delay 200ms loss 10%"
- This adds a 200ms delay and 10% packet loss to Wi-Fi. Replace
wlan0
with the appropriate interface for mobile data (rmnet0
). - To reset, use:
adb shell "tc qdisc del dev wlan0 root"
- This adds a 200ms delay and 10% packet loss to Wi-Fi. Replace
3. Location Simulation for Field Testing
Test app behavior in different geographic locations using mock locations:
- Enable Mock Locations:
adb shell settings put secure mock_location 1
- Ensure your testing app has mock location permissions.
- Simulate a Specific Location:
adb shell am startservice -a com.google.android.gms.location.ACTION_MOCK_LOCATION -e lat 12.9716 -e lon 77.5946
- This simulates the location for Bangalore, India (latitude: 12.9716, longitude: 77.5946).
- Update the
lat
andlon
values to test other locations.
4. Testing Battery Performance in the Field
Monitor battery performance under real-world conditions:
- Monitor Battery Status:
adb shell dumpsys battery
- This displays details like charge level, voltage, and temperature.
- Simulate Low Battery:
adb shell dumpsys battery set level 10
- This sets the battery level to 10% for testing low-battery behavior.
- To reset, use:
adb shell dumpsys battery reset
5. Practical Field Testing Scenarios
Field testing ensures your app performs well under real-world conditions. Here are some scenarios:
- Network Change Testing: Simulate network drops or switches (e.g., Wi-Fi to LTE) and ensure app sessions remain active.
- Battery Optimization Testing: Test app behavior under low-battery conditions, ensuring critical features work as expected.
- Geographic Restrictions: Simulate different locations to test region-specific app features (e.g., currency display, localized offers).
- Offline Functionality: Disable networks to test app behavior in offline mode.
- Performance Testing: Throttle networks to simulate slow connections and validate app responsiveness.
ADB provides a powerful way to simulate and control real-world testing environments, enabling thorough field testing of mobile applications.