Yapitest
Yapitest (Yaml API Testing) is an API testing framework composed entirely of YAML files. Testing is frustrating enough already, and Yapitest aims to simplify the entire process of API testing through a simple interface. Frankly, the entire expect(value).toBe(0) stuff keeps me up at night.
Table of Contents
Disclaimer
Yapitest is still in alpha and there may be some bugs. Feel free to open up a Pull Request or submit an issue and I will try to get it tested and merged as quickly as possible.
Example
The yapitest test format was designed to be as simple as possible. Even if you have never seen a yapitest test before, you can probably infer all of what the test is doing.
Here is an example:
test-create-and-get-post:
setup: create-user
steps:
- path: /api/post/create
id: create-post
method: POST
headers:
API-Token: $setup.token
data:
title: Some Title
body: Some message
assert:
status-code: 201
- path: /api/post/$create-post.response.post_id
assert:
body:
title: "Some Title"
body: "Some message"
-
Firstly, the name of the test (
test-create-and-get-post) gives some indication of what the test is doing. -
There is a
setupwhich is something that runs before the test. This one,create-useris reusable step that creates a user. It is defined in a config file. Similarly, you can specify acleanupwhich is run after the other steps run. -
Then we have the
stepssection, which includes the actual steps of the tests. -
The first step sends a
POSTrequest to/api/post/create, with atitleandbodyin the payload, utilizing an API Token that thesetupgenerated. Then asserts that the status code is201. -
The last step of the test sends a
GETrequest to/api/post/$create-post.response.post_id. This$create-post.response.post_idreferse to the json response of the$create-poststep which has a keypost_idin it. Then inside of theassertblock we ensure that the data in the body contains the propertitleandbodyvalues.
For more information about how to format your tests, please refer to Tests.md.
Installation
To install, run:
pip install yapitest
Then you can run it via yapitest in your terminal.