Files
fn_registry/bash/functions/infra/gradle_unit_test.md
T

2.1 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path, params, output, notes
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports tested tests test_file_path file_path params output notes
gradle_unit_test function bash infra 1.0.0 impure gradle_unit_test(project_dir: string, module: string, --variant <name>: string) -> int Corre unit tests JVM de un modulo Android (no requiere emulador).
android
gradle
kotlin
test
junit
gradle_run_bash_infra
false error_go_core
false
bash/functions/infra/gradle_unit_test.sh
name desc
project_dir Raiz del proyecto Android con settings.gradle[.kts].
name desc
module Modulo Gradle. Default: app
name desc
--variant <name> Build variant (Debug|Release). Default Debug
Stdout con resultados JUnit. Linea final 'REPORT: <path_html>'. Exit code = test runner exit (0 OK, 1 fallos). JVM only — Compose Composables que necesitan device se testean con gradle_instrumented_test. Para tests Compose en JVM usar Roborazzi (gradle_screenshot_test). La funcion hace source de gradle_run.sh desde el mismo directorio (bash/functions/infra/). La dependencia gradle_run_bash_infra debe existir junto a este archivo.

Ejemplo

source bash/functions/infra/gradle_unit_test.sh

# Tests del modulo app con variante Debug (por defecto)
gradle_unit_test /home/lucas/projects/myapp

# Tests del modulo :core con variante Release
gradle_unit_test /home/lucas/projects/myapp core --variant Release

# Verificar que paso
if gradle_unit_test /home/lucas/projects/myapp; then
    echo "Todos los tests pasaron"
else
    echo "Hay tests fallidos — revisar el report HTML"
fi

Notas

JVM only — Compose Composables que necesitan device se testean con gradle_instrumented_test. Para tests Compose en JVM usar Roborazzi (gradle_screenshot_test).

El task ejecutado es :$module:test${variant}UnitTest (ej. :app:testDebugUnitTest). El report HTML se imprime al final como REPORT: <path> para facilitar parseo por agentes o scripts upstream.