Ir al contenido principal
Versión: 6.0

Configuración

[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 framework de pruebas Kotest es compatible con JVM, Javascript, Native y Wasm. Para habilitar Kotest en múltiples plataformas, sigue los pasos para la plataforma que estés utilizando, como se detalla en las siguientes pestañas.

precaución

El soporte para KMP en Kotest 6.0 ha cambiado respecto a versiones anteriores. Ya no hay un plugin del compilador, sino una configuración simplificada. Consulta el resto de esta página para obtener detalles sobre cómo configurar Kotest para KMP en Kotest 6.0 y versiones posteriores.

consejo

Al ejecutar la tarea de pruebas de Gradle, Gradle almacenará en caché la salida e informará que no se han ejecutado pruebas si no ha cambiado ningún código fuente. Consulta la sección sobre cómo volver a ejecutar pruebas para obtener detalles sobre cómo deshabilitar este comportamiento.

consejo

A working project with JVM support can be found here: https://github.com/kotest/kotest-examples

Kotest on the JVM has two ways for running tests. One uses the Kotest gradle plugin, which provides detailed test output in the console, and a rich experience in Intellij (in conjuction with the Intellij Kotest plugin). The other option uses the JUnit Platform gradle plugin which is ubiquitous in the JVM ecosystem but lacks some features of the Kotest gradle plugin.

To use the Kotest gradle plugin, add the following to your build.gradle.kts file:

plugins {
id("io.kotest") version "<kotest-version>"
}

Add the following dependency to your build:

dependencies {
testImplementation("io.kotest:kotest-framework-engine:$version")
}

And then execute the jvmKotest task in gradle, or run tests directly from the IDE.

To use the JUnit Platform plugin, add the following to your build.gradle.kts file:

tasks.withType<Test>().configureEach {
useJUnitPlatform()
}

Add the following dependency to your build:

dependencies {
testImplementation("io.kotest:kotest-runner-junit5:$version")
}

And then execute the test task in gradle, or run tests directly from the IDE.

Volver a ejecutar pruebas

Por defecto, la compilación incremental de Gradle omitirá la ejecución de pruebas si no ha cambiado ningún código fuente, marcando la tarea como UP-TO-DATE. Esto puede resultar inconveniente durante la depuración.

Para forzar que tus pruebas se ejecuten cada vez, puedes añadir temporalmente la siguiente configuración en tu archivo build.gradle.kts:

tasks.withType<Test>().configureEach {
logger.lifecycle("UP-TO-DATE check for $name is disabled, forcing it to run.")
outputs.upToDateWhen { false }
}

Alternativa rápida: Para volver a ejecutar una sola vez sin modificar los archivos de construcción, puedes usar la opción --rerun desde la línea de comandos:

./gradlew test --rerun