> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xenoci.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Test

> Your JVM unit tests on a clean machine, each failure by name

> [!NOTE]
>
> **When to use it.** Before you push, run the project’s unit tests on a clean machine and get the failing test by name

## Run it

```bash theme={"system"}
box test --platform android
```

<video controls muted loop playsInline autoPlay preload="metadata" poster="/media/docs/android-test-poster.webp" src="https://mintcdn.com/xenoci/ZFKGlbE4Q2bw14Om/media/docs/android-test.mp4?fit=max&auto=format&n=ZFKGlbE4Q2bw14Om&q=85&s=69a68f332f1b3878d59fb1b7d5fece0a" width="1280" height="778" />

box test --platform android: 1 passed, 0 failed

XenoCI Box runs Gradle `testDebugUnitTest`: every JVM unit test under `src/test`. Instrumented tests under `src/androidTest` do not run, and `--only-testing` is not used on Android

JetLagged ships only instrumented tests, so for this page we added one test file to the sample, with one test that fails on purpose (and `testImplementation(libs.junit)` in `app/build.gradle.kts`)

```bash theme={"system"}
package com.example.jetlagged

import org.junit.Assert.assertEquals
import org.junit.Test

class SleepMathTest {
    @Test
    fun hoursAddUp() {
        assertEquals(8, 7 + 1)
    }

    @Test
    fun weekHasSevenDays() {
        assertEquals(7, listOf("Fri", "Sat", "Sun", "Mon", "Tue", "Wed").size)
    }
}
```

```text theme={"system"}
$ box test --platform android
box: upload: 75 files checked, 2 new (6 KB), .gitignore respected, .env never sent (snapshot snap_tiQkLXWoiPBpBJ4o)
box: queue: job bj_n-iRg8tpNO0S3RD5 (test, android, $0.02/min) submitted
…
SleepMathTest > weekHasSevenDays FAILED
    java.lang.AssertionError at SleepMathTest.kt:14
2 tests completed, 1 failed
…
box: status: failed
box: results: saved to ./.box/out/bj_n-iRg8tpNO0S3RD5/ (test.log, test-summary.json)
box: tests 1 passed, 1 failed
  FAIL com.example.jetlagged.SleepMathTest/weekHasSevenDays
box: bj_n-iRg8tpNO0S3RD5 failed, 60s billed, $0.02
```

> [!NOTE]
>
> Job `bj_n-iRg8tpNO0S3RD5` on a production Android machine: 60s billed, \$0.02

## What you get

* One line per failing test (`FAIL class/test`) and a count; the job exits 1 when a test fails
* `.box/out/<job>/test.log`, the Gradle log, and `test-summary.json`, the counts and the failing test names
* `--json` prints one JSON event per line, so an agent reads the result without parsing text

![The JetLagged sample the tests ran against, open on an Android emulator](https://mintcdn.com/xenoci/ZFKGlbE4Q2bw14Om/images/docs-android-run.png?fit=max\&auto=format\&n=ZFKGlbE4Q2bw14Om\&q=85\&s=ffa89d011d44c7246cd4b3eab299e239)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.