百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

mao

> 编程语言
开源

适用于 Go 的 Pragmatic BDD 测试框架

100 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

适用于 Go 的 Pragmatic BDD 测试框架

Māo

Pragmatic BDD Testing Framework For Go.

go
import "math"

Desc("math.Abs", func(it It) {
  it("returns the absolute value of x", func(expect Expect) {
    expect(math.Abs(-12)).Equal(12.0)
    expect(math.Abs(-.5)).Equal(0.5)
  })
})

Why Māo?

  • More flexibility: You can locate your tests in any directory.
  • Don't repeat yourself: Māo does the ceremony for you by preprocessing the test module.
  • Minimalistic Output: Māo doesn't have verbose outputs. It'll output short and briefly, will show you what lines fail in case of any error.

Update: Development Status

Install

Install the Go library first;

bash
$ go install github.com/azer/mao

And optionally, install the command-line tool to avoid the boilerplate code: See examples/simple-with-boilerplate.go if you'd like to skip this step

bash
$ curl https://raw.github.com/azer/mao/master/install | sh

Usage

Create a test module anywhere you want and import the code you'd like to test:

go
import "math/rand" // or: import "github.com/you/repository"

Desc("math.Abs", func(it It) {
  it("returns the absolute value of x", func(expect Expect) {
    expect(math.Abs(-12)).Equal(12.0)
    expect(math.Abs(-.5)).Equal(0.5)
  })
})

And run it with mao command:

bash
$ mao test.go

It'll either output a simple success message that will look like;

Ran 3 tests successfully.

Or some error messages with failing source code lines, like following;

Reference

BDD API

  • Desc
  • It
  • BeforeEach
  • AfterEach

Assertion API

  • Above
  • Equal
  • NotEqual
  • NotExist
  • ResponseBody
  • Lower

Development Status

I recently think of two major changes in the project;

  • Rewriting the preprocesser (bash script) in Go
  • Replacing "desc/it" with "test".

So it'd be looking like;

go
import "math"

Test("returns the absolute value of x", func(e Expect) {
  expect(math.Abs(-12)).Equal(12.0)
  expect(math.Abs(-.5)).Equal(0.5)
})

At this point, I wouldn't recommend to use Mao. I still have the same goal but it may cause some pain since its preprocesser is not reliable enough.

And since other projects occupy my time nowadays, I'd appreciate pull requests to reach the goals of the project. Thanks for your interest!

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Go

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言