> ## 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.

# Why it failed

> When a job fails, box saves the evidence only the Mac has, the failing test or crash with its file and line, as why.txt, and its last line tells you where

> [!NOTE]
>
> **When to use it.**
>
> * A build, test or exec job failed and you want the cause before reading the whole log
> * Your agent should fix the right line instead of guessing from a cut log

## Read why.txt

The failing test from the [Test](https://docs.xenoci.com/ios/test.md) page ended like this

```text theme={"system"}
box: tests 1 passed, 1 failed
  FAIL BoxDemoTests/testCountStartsAtOne(): XCTAssertEqual failed: ("0") is not equal to ("1") - the counter should start at 1
box: bj_aDxtZUJUe0bpuoFx failed, 180s billed, $0.15
box: why: FAIL BoxDemoTests/testCountStartsAtOne(): XCTAssertEqual failed: ("0") is not equal to ("1") - the counter should start at 1
box: details: .box/out/bj_aDxtZUJUe0bpuoFx/why.txt
```

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

A failing test: box prints the failing line and saves why.txt

```bash theme={"system"}
cat .box/out/bj_aDxtZUJUe0bpuoFx/why.txt
```

```bash theme={"system"}
FAIL BoxDemoTests/testCountStartsAtOne() at /Users/admin/xenoci-box/src/BoxDemoTests/BoxDemoTests.swift:7: XCTAssertEqual failed: ("0") is not equal to ("1") - the counter should start at 1
```

`/Users/admin/xenoci-box/src/` is your project folder on the Mac, so the line to fix is `BoxDemoTests/BoxDemoTests.swift:7` in your copy

## A failing UI test

A UI test taps Add once and expects the counter to show 2. It saves the screen before the check with `XCTAttachment(screenshot:)`

```bash theme={"system"}
box test
```

```text theme={"system"}
box: tests 1 passed, 1 failed
box: bj_KISeZPAtJ5ZsWr3C failed, 60s billed, $0.05
box: why: FAIL BoxDemoUITests/testAddTwiceShowsTwo(): XCTAssertEqual failed: ("Count: 1") is not equal to ("Count: 2") - two taps on Add should show 2
box: details: .box/out/bj_KISeZPAtJ5ZsWr3C/why.txt
```

```bash theme={"system"}
FAIL BoxDemoUITests/testAddTwiceShowsTwo() at /Users/admin/xenoci-box/src/BoxDemoUITests/BoxDemoUITests.swift:11: XCTAssertEqual failed: ("Count: 1") is not equal to ("Count: 2") - two taps on Add should show 2
```

![The example app at the moment the UI test failed: Count: 1 after one tap on Add](https://mintcdn.com/xenoci/ZFKGlbE4Q2bw14Om/images/docs-why-screen.png?fit=max\&auto=format\&n=ZFKGlbE4Q2bw14Om\&q=85\&s=1f1c7a0ab2b83e22e4514f6f9964ccbf)

The screen the test saved, from `test.xcresult.zip` of that job (open it in Xcode), made smaller for this page. It shows Count: 1, so the test, not the app, is wrong

> [!NOTE]
>
> Job `bj_KISeZPAtJ5ZsWr3C` on the production Mac: 60 s billed, \$0.05

## The lines to look for

* `box: why:` the cause in one line
* `box: details:` where `why.txt` was saved
* `box: looks like our side` appears only when the Mac, a time limit or a lost connection ended the job. Then run `box report <job> --reason "..."` for a refund. Your own compile or test errors never show it

## Exit codes

* `1`: your build or tests failed. Fix the code and run it again
* `3`: our side or your account (signed out, an outage). Do not retry it in a loop


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