lundi 25 avril 2016

Should integration tests for API check that it actually creates database entries?

I have written a small REST API using Flask-Restul. Now I would like to add some integration tests to ensure that my API behavior meets expectations and doesn't change when I will be refactoring it.

Suppose that I have an endpoint, say, /objects which responds to POST request. Upon POST request the endpoint creates a new resource (an entry in database) and responds with it JSON representation to client.

Should I check in my tests that the endpoint actually creates entries in database or seeing 201 response code + json body is enough?

It feels like I should not check it as I test API as a consumer, but at the same time I want to be adamant that it updates DB.

Aucun commentaire:

Enregistrer un commentaire