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

# 使用 Bun 测试运行器将测试标记为"待办"

要提醒自己稍后编写测试，请使用 `test.todo` 函数。不需要提供实现。

```ts test.ts icon="https://mintcdn.com/span-inc/82N53aP7NFbaCVSl/icons/typescript.svg?fit=max&auto=format&n=82N53aP7NFbaCVSl&q=85&s=787d39d6a7d96d7f9540dc74344eba23" theme={null}
import { test, expect } from "bun:test";

// 稍后编写
test.todo("未实现的功能");
```

***

`bun test` 输出会报告 `todo` 测试的数量。

```sh terminal icon="terminal" theme={null}
bun test
```

```txt theme={null}
test.test.ts:
✓ add [0.03ms]
✓ multiply [0.02ms]
✎ 未实现的功能

 2 通过
 1 待办
 0 失败
 2 个 expect() 调用
跨 1 个文件运行了 3 个测试。 [74.00ms]
```

***

你可以提供测试实现。

```ts theme={null}
import { test, expect } from "bun:test";

test.todo("未实现的功能", () => {
  expect(Bun.isAwesome()).toBe(true);
});
```

***

除非传入 `--todo` 标志，否则 Bun 不会运行该实现。使用 `--todo` 时，测试会运行并且*预期会失败*。如果待办测试通过了，`bun test` 会返回非零退出码。

```sh terminal icon="terminal" theme={null}
bun test --todo
```

```txt theme={null}
my.test.ts:
✗ 未实现的功能
  ^ 此测试标记为待办但通过了。如果测试的行为现在已生效，请删除 `.todo`

 0 通过
 1 失败
 1 个 expect() 调用
$ echo $?
1 # 这是上一条命令的退出码
```

***

参见：

* [跳过测试](/guides/test/skip-tests)
* [编写测试](/test/writing-tests)
