Middle+
Tell us about cases of reconnection checks in a mobile application.
sobes.tech AI
Answer from AI
Reconnection tests verify how a mobile application behaves when losing and subsequently restoring a connection to a server or other network resources.
Test scenarios:
- Network switching:
- Wi-Fi -> Mobile internet (LTE/5G).
- Mobile internet (LTE/5G) -> Wi-Fi.
- Wi-Fi (one access point) -> Wi-Fi (another access point).
- Signal loss:
- Entering a coverage zone without signal (elevator, metro).
- Enabling/disabling "Airplane mode".
- Forcibly disabling network interfaces (Wi-Fi, Cellular Data) through device settings.
- Server issues:
- Temporary API unavailability.
- Server reboot.
- Network delays (simulated with proxy servers).
What we check:
- UI/UX behavior:
- Displaying loading indicators or errors.
- Preserving current user state (e.g., incomplete input, list position).
- Correctly displaying notifications about connection loss/restoration.
- No application crashes or "hangs".
- Data integrity:
- Data in the process of sending/receiving during disconnection should be correctly handled after restoration.
- Locally stored data should synchronize with the server.
- Retry logic:
- The app should have retry logic with exponential backoff.
- Limits on retry count and wait time.
- Session handling:
- User session should be preserved or correctly restored without forced logout.
Tools and techniques:
- Network proxies: Charles Proxy, Fiddler. Used to simulate delays, packet drops, request blocking.
- Network utilities: Developer tools in browsers (for WebView), specialized mobile traffic control utilities.
- "Airplane mode": A simple way to simulate complete connection loss.
- Disabling network interfaces: Through device system settings.
- Network emulators: Tools to simulate various network conditions (speed, delay, packet loss).
- Automation: Using Appium, Espresso (Android), XCUITest (iOS) for automating network switching scenarios or calling system functions (enabling/disabling Airplane Mode).
// Example of automating reconnection test with Appium (Python)
from appium import webdriver
import time
desired_caps = {
'platformName': 'Android',
'deviceName': 'Android Emulator', # Or real device
'appPackage': 'com.yourapp.package',
'appActivity': 'com.yourapp.MainActivity',
'automationName': 'UiAutomator2'
}
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
try:
// Perform actions requiring network
driver.find_element_by_accessibility_id("some_button").click()
time.sleep(5) # Wait for data to load
// Enable "Airplane mode"
driver.open_notifications()
driver.find_element_by_accessibility_id("Airplane mode").click()
driver.back() # Close notifications
print("Airplane mode ON")
time.sleep(10) # Wait for connection loss
// Attempt a network action
driver.find_element_by_accessibility_id("another_button").click()
// Check for error/no network indicator
// Disable "Airplane mode"
driver.open_notifications()
driver.find_element_by_accessibility_id("Airplane mode").click()
driver.back() # Close notifications
print("Airplane mode OFF")
time.sleep(10) # Wait for connection restoration
// Verify functionality and data correctness
// ... assert statements ...
except Exception as e:
print(f"Error: {e}")
finally:
driver.quit()
Reconnection testing is critical for ensuring the stability and reliability of a mobile application under unstable network conditions.