Using Android and testing on the device, I use this to check, if WiFI is connected:
ConnectivityManager manager = (ConnectivityManager) MyApplication.getMyApplication().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
return info.isConnectedOrConnecting();
Works well. Is there a way to mock this for JUnit?
Thanx in advance,
Marcus
you can mock this functionality if you move the code into your own WifiServiceClass and let you application depend on the interface: