Tavern API testing....nice little pytest plugin

As the title says really. I’ve been looking for something a bit more lightweight than Postman for API testing. My plan is for my Django app to have unit, API and GUI tests for practice.

Tavern is an awesome plugin, uses pytest, and the tests are written in YAML so they are super-easy to construct.

Being part of the pytest family means you can run your API suites, take advantage of pythons ecosystem, the same as frontend and unit tests, all in one structure/location.

Simple example from site:

test_name: Get some fake data from the JSON placeholder API

        - name: Make sure we have the right ID
           # Define the request to be made
               url: https://jsonplaceholder.typicode.com/posts/1
               method: GET
         # ... and the expected response code and body
              status_code: 200
                  id: 1

So easy to read and write. And what I really like is that you can poke away and explore with ‘requests’ on the command line, and then pop it into YAML when you want to formalise the test into the suite.


Nice, that’ll come in handy.