Coder Social home page Coder Social logo

sigoden / apitest Goto Github PK

View Code? Open in Web Editor NEW
107.0 6.0 10.0 408 KB

Apitest is declarative api testing tool with JSON-like DSL.

License: MIT License

TypeScript 72.67% JavaScript 27.33%
ci tdd api-testing jsona testrunner testing-tool test-automation

apitest's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

apitest's Issues

Add @optional

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
    }
  }
}

Enhancement: @openapi

很多项目自带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,邀请大家一起讨论下是否有必要引入这个特性,如何简单自然的引入。

Add @nullable ?

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
    }
  }
}

Enhancement: unit.run

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.

skip

{
    test1: {@client("echo")
        req: {
        },
        run: {
            skip: true,
        }
    }
}
  • run.skip skip the test when true

retry

{
    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 retry
  • run.retry.delay interval between each retry (ms)

loop

{
    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 index
  • run.loop.data loop fill to $run.loop data
  • run.loop.delay interval between each cycle (ms)

very good

It's the best Api auto test tools, i have ever seen.

Can I add proxy?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.