Skip to content

Commit

Permalink
fix(test): DNS error test should wait for MQTT connection to fail
Browse files Browse the repository at this point in the history
  • Loading branch information
growse committed Oct 5, 2024
1 parent 58eb18c commit 5925ce3
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import androidx.test.platform.app.InstrumentationRegistry
import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertContains
import com.adevinta.android.barista.interaction.BaristaSleepInteractions.sleep
import com.fasterxml.jackson.databind.ObjectMapper
import java.net.ConnectException
import java.net.InetSocketAddress
Expand Down Expand Up @@ -78,6 +79,7 @@ class ConnectionErrorTest :
this[Preferences::host.name] = "unknown"
})
setupActivity(config)
app.mqttConnectionIdlingResource.use { Espresso.onIdle() }
assertContains(R.id.connectedStatusMessage, R.string.statusEndpointStateMessageUnknownHost)
}
}
Expand Down Expand Up @@ -238,6 +240,7 @@ private fun Broker.use(block: () -> Unit) {
Timber.i("Test MQTT Broker listening on port ${this.port}")
} catch (e: ConnectException) {
Timber.i("broker not listening on ${this.port} yet")
listening = false
Thread.sleep(5000)
}
}
Expand Down

0 comments on commit 5925ce3

Please sign in to comment.