Collections of API tests in Postman and Insomnia

Colleagues, I wish you all a good day.

For beginner testing specialists

Author: Nadezhda Dudnik

I recently shared information on how to create test cases for the backend (read the article API test case templates, idempotency test cases).

Now I want to demonstrate examples of creating queries based on data test cases for site:

UI: https://try.vikunja.io/login
API documentation: https://try.vikunja.io/api/v1/docs

Let’s look at the following functional checks on API:

New User Registration
Registering with an existing username
Registration with existing email
Successful authorization and receipt of a token
Creating a project
Getting project information by id
Updating a project by id
Deleting a project by id
Creating a task
Getting all tasks in a project
Getting task information by id
Updating a task by id
Deleting a task by id
Adding a label to a task (you can add several)
Creating a label
Getting all labels in a task
Getting label information by id
Updating a label by id
Removing a tag by id

Creating queries based on test cases in tools:

Postman

Postman (Version 10.20.3, OS platform win32 10.0.19045 at the time of writing)

This is what a collection of queries looks like:

Collection "Vikunja API" in Postman

Collection “Vikunja API” in Postman

Variables with their values ​​are declared in the collection itself:

Necessary variables for work

Necessary variables for work

Code on the tab Tests to set variables to the collection:

в запросе POST Login

var jsonData = JSON.parse(responseBody);
pm.collectionVariables.set("token", jsonData.token);

Токен можно объявить или через вкладку "Headers" как Authorization: Bearer {{token}} 
или
через вкладку "Authorization" -> type 'Bearer Token'
в запросе PUT Creates a new project

var jsonData = JSON.parse(responseBody);
pm.collectionVariables.set("project_id", jsonData.id);
в запросе PUT Create a task

var jsonData = JSON.parse(responseBody);
pm.collectionVariables.set("task_id", jsonData.id);
в запросе PUT Create a label

var jsonData = JSON.parse(responseBody);
pm.collectionVariables.set("label_id", jsonData.id);

Example of a request and response from the server:

PUT Create a task

PUT Create a task

View and download the collection: link to collection

Insomnia

Insomnia (Version: Insomnia 8.4.5, OS: Windows_NT x64 10.0.19045 at the time of writing)

This is what a collection of queries looks like:

Collection "Vikunja API" in Insomnia

Collection “Vikunja API” in Insomnia

Variables with their values ​​are declared in the environment:

Necessary variables for work

Necessary variables for work

The values ​​of the variables are taken as follows:

example of editing a variable: more details can be found here

example of editing a variable: more details can be found here

Example of a request and response from the server:

PUT Create a task

PUT Create a task

View and download the collection: link to collection

Conclusion

Based on these examples, I showed how to write queries and build a collection structure in Postman and Insomnia.

It is planned to introduce check scripts.

These examples will help not only in building queries, but also in writing functional test cases for the API during training and even at work.

Thanks for reading.

Sincerely, Nadezhda Dudnik (protestinginfo), chief testing engineer in fintech and software testing mentor.

And I wish you to achieve your goal!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *