Skip to content

测试

Targo 测试遵循 Go 的测试模型,而不是 Jest / Vitest 模型。

文件命名

支持的测试文件模式:

  • *_test.ts
  • *.test.ts

都会编译成 *_test.go

函数签名

单元测试

typescript
import * as testing from "testing";

export function TestAdd(t: testing.T): void {
  // ...
}

Benchmark

typescript
import * as testing from "testing";

export function BenchmarkAdd(b: testing.B): void {
  // ...
}

运行

  • targo test
  • targo test --run <pattern>
  • targo test --bench <pattern>
  • targo test --cover