samedi 12 septembre 2015

REST API Testing: Unit tests with mocks vs. testing from the "outside"

I am building a stateless RESTful API using Pyramid framework. Now Pyramid gives a good testing skeleton to write unit tests, but we need to do view config, mocks, etc., to get tests working.

I was thinking about testing the API from the "outside", meaning using something like the requests library to drive the API as if it were being used by a real client, and "somehow" reporting failures just like unit tests.

Here are my questions...

  1. Is what I am thinking really absurd?
  2. Can these two approaches be used together? Can they be used exclusively?
  3. If these can be used together, what aspects should I test in unit tests and what from the outside?
  4. Anything else that's relevant in this context?

I guess, essentially, I am asking, what benefits do unit tests have over integration tests in a RESTful API testing context.

Aucun commentaire:

Enregistrer un commentaire