First of all: code and tests are separated from each other, so the person writing tests does not need to know how to code.
You can find them in java/src/test/resources looking like:
groups:
- name: user tests
domain: http://localhost:8080
tests:
- name: create new user
request:
method: POST
uri: /user
body: '@testdata.json'
headers:
Accept: 'application/json'
Content-Type: 'application/json'
response:
headers:
Content-Type: 'application/json; charset=utf-8'
status: 201
body: '{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "[email protected]"
}'
You can upload a binary by referencing the filename in the body
tag. When
no leading slash is found, the file is referenced from the current directory.
- name: upload image file
domain: http://localhost:8080
tests:
- name: upload file
request:
method: PUT
uri: /resource/test.jpg
headers:
Content-Length: 63058
Content-Type: image/jpeg
body: '@test.jpg'
response:
status: 201
headers:
Etag: a12bae32eb58b25d6cbdb5588d582741
Location: /resource/test.jpg
You test if the response matches a binary by specifying a file in the body
tag.
- name: download file
request:
method: GET
uri: /resource/test.jpg
response:
status: 200
headers:
Content-Length: 63058
Content-Type: image/jpeg
Etag: a12bae32eb58b25d6cbdb5588d582741
body: '@test.jpg'
The test will only be valid when both binary streams are identical.
If you want to test if the body is really empty, you can specify:
body: ''
$ java -jar target/aiko-x.y-SNAPSHOT.jar -f src/test/resources/jsonplaceholder-tests.yml
- After the first error tests in containing group exit with message and next group is tested.
- The order of json elements in each response is unconsidered.
- The request-part constructs your request (multiple - for example - headers are possible).
- The response-part is compared to the real response and differences are shown.
- The request or response body can be referenced in a file (put '@' before path).
- There is a configurable retry mechanism rechecking per testcase.
- There already are a few test configurations inside java/src/test/resources to show what is possible.
Have fun! :)