In my unit test I am calling the following:
every { connectivityManager.activeNetworkInfo } returns null
but when I debug I get a NetworkInfo object filled with null and false values
networkInfo = {NetworkInfo@9780}"[type: null[null], state: null/null, reason: unspecified), extra: (none), failover: false, available: false, roaming: false]"
therefore this null check in my implementation does not yield false and I cannot verify the "false" path.
val networkInfo = connectivityManager?.activeNetworkInfo
if (networkInfo != null) { ... }
I am calling this deprecated getActiveNetworkInfo() method because I need to support Android 8.0 8.1 and 9.
what am I missing?
CodePudding user response:
Ok I found the problem, the code above works, my problem was that I did not pass my mocked objects correctly so the mocked code never was executed.