sigoden / apitest Goto Github PK
View Code? Open in Web Editor NEWApitest is declarative api testing tool with JSON-like DSL.
License: MIT License
Apitest is declarative api testing tool with JSON-like DSL.
License: MIT License
Some api may return some optional fields, which will be returned when the field has a value.
In this case, it is necessary to add an annotation @optional
{
test1: { @client("echo")
req: {
v1: 3,
// v2: 4, optional field
},
res: {
v1: 3,
v2: 4, @optional
}
}
}
Can be used with other annotations
{
test1: { @client("echo")
req: {
v1: 3,
// v2: 4, optional filed
},
res: {
v1: 3,
v2: 0, @type @optional
}
}
}
很多项目自带OpenApi/Swagger文档。
OpenAPI中包含了接口的路由信息,并定义了接口请求和响应的数据结构。
这些其实可以被测试项目复用的。
是否可以通过@openapi注解复用 OpenApi 中的信息?
{
// 引入openapi文档
@openapi("api")
// 支持多个openapi文档
@openapi("apiManage")
// 复用addPet路由信息
addPet1: { @openapi("api#addPet")
req: {
body: {
}
},
res: {
// 使用JsonSchema校验响应数据
body: { @openapi("api#Pet")
}
}
}
}
这是个开放的Issue,邀请大家一起讨论下是否有必要引入这个特性,如何简单自然的引入。
body:[
{
code: "Errloginuser", @string
message: "您还未注册", @string
}
]
返回的是一个数组对象,如何优雅的验证
例如:
response.body.data.list.length > 0
Some fields may return null when there is no value, and return a specific value when there is a value.
Although we can use @some
{
test1: { @client("echo")
req: {
v1: 3,
v2: null,
// v2: {k: "v"}
},
res: {
v1: 4,
v2: [ @some
null,
{k: "v"},
]
}
}
}
But it is a bit cumbersome to write. Is it necessary to add @nullable
syntactic sugar?.
{
test1: { @client("echo")
req: {
v1: 3,
v2: null,
// v2: {k: "v"}
},
res: {
v1: 4,
v2: {k: "v"}, @nullable
}
}
}
In some scenarios, use cases may not need to be executed, or they may need to be executed repeatedly. It is necessary to add a run
option to support this feature.
{
test1: {@client("echo")
req: {
},
run: {
skip: true,
}
}
}
run.skip
skip the test when true{
test1: {@client("echo")
req: {
},
run: {
retry: {
stop:'$run.retry.count> 2', @eval
delay: 1000,
}
},
}
}
$run.retry.count
records the number of retries.
run.retry.stop
whether to stop retryrun.retry.delay
interval between each retry (ms){
test1: {@client("echo")
req: {
v1:'$run.loop.index', @eval
v1:'$run.loop.item', @eval
},
run: {
loop: {
delay: 1000,
data: [
'a',
'b',
'c',
]
}
},
}
}
$run.loop.data
current loop data$run.loop.index
current loop data indexrun.loop.data
loop fill to $run.loop
datarun.loop.delay
interval between each cycle (ms)It's the best Api auto test tools, i have ever seen.
如题
I'd like to use apitest for CI. But My CI system is isolated from running env, but socket or http proxy is available. Is there a way to add proxy for apitest?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.