Ir al contenido principal
Versión: 5.2.x

Matchers para Ktor

[Traducción Beta No Oficial]

Esta página fue traducida por PageTurner AI (beta). No está respaldada oficialmente por el proyecto. ¿Encontraste un error? Reportar problema →

El código se encuentra en un repositorio separado y en un grupo diferente: io.kotest.extensions.

Dependencia completa

implementation("io.kotest.extensions:kotest-assertions-ktor:version")

implementation "io.kotest.extensions:kotest-assertions-ktor:version"

El módulo kotest-assertions-ktor proporciona matchers para Ktor.

Respuesta de la aplicación de prueba

Los siguientes matchers se utilizan al realizar pruebas mediante el testkit de servidor de Ktor.

MatcherDescription
TestApplicationResponse.shouldHaveStatus(HttpStatusCode)Asserts that the response had the given http status code
TestApplicationResponse.shouldHaveContent(content)Asserts that the response has the given body
TestApplicationResponse.shouldHaveContentType(ContentType)Asserts that the response has the given Content Type
TestApplicationResponse.shouldHaveHeader(name, value)Asserts that the response included the given name=value header
TestApplicationResponse.shouldHaveCookie(name, value)Asserts that the response included the given cookie
TestApplicationResponse.shouldHaveCacheControl(value)Asserts that the response included the given cache control header
TestApplicationResponse.shouldHaveETag(value)Asserts that the response included the given etag header
TestApplicationResponse.shouldHaveContentEncoding(value)Asserts that the response included the given content encoding header

HttpResponse

Los siguientes matchers pueden utilizarse con respuestas del cliente HTTP de Ktor.

MatcherDescription
HttpResponse.shouldHaveStatus(HttpStatusCode)Asserts that the response had the given http status code
HttpResponse.shouldHaveContentType(ContentType)Asserts that the response has the given Content Type
HttpResponse.shouldHaveHeader(name, value)Asserts that the response included the given name=value header
HttpResponse.shouldHaveVersion(HttpProtocolVersion)Asserts that the response used the given protocol version
HttpResponse.shouldHaveCacheControl(value)Asserts that the response included the given cache control header
HttpResponse.shouldHaveETag(value)Asserts that the response included the given etag header
HttpResponse.shouldHaveContentEncoding(value)Asserts that the response included the given content encoding header