Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

【自荐工具】 Apitest —使用类JSON的DSL编写测试用例的自动化测试工具 #1788

Closed
sigoden opened this issue Jun 4, 2021 · 0 comments

Comments

@sigoden
Copy link

sigoden commented Jun 4, 2021

源码

github.com/sigoden/apitest

特性

  • 类JSON的DSL编写用例
  • 跨平台,跨编程语言
  • 支持Mock
  • 数据即断言
  • 数据即变量
  • 支持Mixin
  • 支持CI
  • 支持TDD
  • 用户定义函数

快速开始

编写测试文件 httpbin.jsona

{
  test1: {
    req: {
      url: "https://httpbin.org/post",
      method: "post",
      header: {
        'content-type': 'application/json',
      },
      body: {
        v1: "bar1",
        v2: "Bar2",
      },
    },
    res: {
      status: 200,
      body: { @partial
        json: {
          v1: "bar1",
          v2: "bar2"
        }
      }
    }
  }
}

运行测试

apitest httpbin.jsona

module main
  unit test1 (0.944) ✘
  main.test1.res.body.json.v2: bar2 ≠ Bar2

  ...

用例测试失败,从Apitest打印的错误信息中可以看到, main.test1.res.body.json.v2 的实际值是 Bar2 而不是 bar2

我们修改 bar2Bar2 后,再次执行 Apitest

apitest httpbin.jsona

module main
  unit test1 (0.930) ✔

这次测试通过了。

@sigoden sigoden changed the title [自荐工具] Apitest —使用类JSON的DSL编写测试用例的自动化测试工具 【自荐工具】 Apitest —使用类JSON的DSL编写测试用例的自动化测试工具 Jun 4, 2021
@sigoden sigoden closed this as completed Mar 22, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants