mirror of
https://github.com/square/okhttp.git
synced 2025-07-29 17:41:17 +03:00
Switch to assertFailsWith (#8177)
* Switch to assertk.fail * Use assertFailsWith * More assertFailsWith * Use more assertFailsWith * More assertFailsWith * More assertFailsWith * Native image dependencies * Move JUnit dependency * Don't lock in a specific implementation class * Missing finally
This commit is contained in:
@ -20,8 +20,9 @@ dependencies {
|
||||
api(libs.squareup.okio)
|
||||
api(libs.kotlin.stdlib)
|
||||
|
||||
testImplementation(libs.kotlin.test.common)
|
||||
testImplementation(libs.kotlin.test.annotations)
|
||||
testImplementation(libs.kotlin.test.common)
|
||||
testImplementation(libs.kotlin.test.junit)
|
||||
testApi(libs.assertk)
|
||||
testImplementation(projects.okhttpTestingSupport)
|
||||
testImplementation(libs.kotlinx.coroutines.test)
|
||||
|
@ -24,6 +24,7 @@ import assertk.assertions.isEqualTo
|
||||
import assertk.assertions.isTrue
|
||||
import java.io.IOException
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.test.assertFailsWith
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
@ -141,15 +142,12 @@ class SuspendCallTest {
|
||||
|
||||
val call = client.newCall(request)
|
||||
|
||||
try {
|
||||
assertFailsWith<IOException> {
|
||||
call.executeAsync().use {
|
||||
withContext(Dispatchers.IO) {
|
||||
it.body.string()
|
||||
}
|
||||
}
|
||||
fail("No expected to get response")
|
||||
} catch (ioe: IOException) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user