Should you use another endpoint for assertion in an integration test for a REST API?

Viewed 109

I have a REST API and I want to write an integration test for a POST endpoint, which creates a Foo item in the database. In the test scenario I am making a request to this POST endpoint. In the assertion part of the test, should I check the database to see if the endpoint in fact inserted the item posted, or should I call a GET endpoint for the Foo entities of the REST API and see if that returns the correct result?

I saw the latter in many examples, but it seems wrong to me, like I am testing two things with two API calls in a single test case. I can imagine a scenario where both my POST and GET endpoints are faulty, and the test still goes green that way.

0 Answers
Related