Approach for testing against mysql DB - integration tests

Viewed 26

Looking for advice for integration tests of data sent to DB. I'm using sqlalchemy as a DB client and not sure what would be the best practice for testing:

  1. Should I use a real mysql DB using docker image for testing purposes with the exact schema of production? Each test will put prerequisite data in DB in an input pytest fixture, and clean up at the end of the test.
  2. Using some DB mocking service such as this one: https://factoryboy.readthedocs.io/en/stable/introduction.html

If somebody had experience with both options or have another one I will be glad to hear pros and cons from your view.

0 Answers
Related