September 21, 2021

Api tests VS unitests

Api tests VS unitests

Hey!

I wonder what is the difference between regular unit tests to Api tests.

A unit test is mocked and thus checks only the business logic, and an api test is not mocked (right?) and thus acts as a kind of an integration test?

Postman for example allows making Api tests, but for example If would do a unit test for an entire endpoint within my Api, when everything is mocked, isn't it better than a regular Api test which checks the status code and other stateless data returning with the request, while ignoring whatever is stateful?

When should I right Api tests, when should I write unitests and what are the advantages or disadvantages of each approach?

Thank you!

submitted by /u/gggal123
[link] [comments]