Ask HN: How do you test SQL?
663 pointsI've been looking for resources for our data team to apply best practices for testing SQL pipelines (we use DBT) but have not found anything. How do you test SQL pipelines? What patterns, tools and best practices would you recommend? Any good reference material you know of?
Comments (315) 98 threads
Earlier commentsLook at this JetBrains survey: https://www.jetbrains.com/lp/devecosystem-2021/databases/
Around half of the people never debug stored procedures. Three quarters of people don't have tests in their databases. Only half of the people version their database scripts.
Personally: the answer is containers. Spin up a database in a container (manually or on CI server) and do whatever you need with it. Seed it with some test data, connect an app to it, check that app tests pass when writing to and reading from a live database (as opposed to mock data stores or something like H2), then discard the container.
Even if you don't have a traditional app, throwaway instances of the real type of DB that you'll be using are great, both for development and testing.
I would love testing to work.
Have set up and maintained several unit test suites in Jest.
Wrote several large e2e test suites in Cypress.
I don't think anyone won time from simply having a manual checklist and testing manually.
Maybe me and my former teammates are doing it wrong. Talking 8+ teams, from corporate to startup.
But loved de proven wrong. E2e def. catched most issues.
Also testing with a checklist by human is easy to outsource to cheap labor. Whereas testing engineers are pretty expensive
It's a lot faster and easier than dealing with containers and the like.
All comments shown.
Couldn't load more comments. Check your connection and try again.