Hacker News new | ask | show | jobs
by cosmotic 1523 days ago
Every time unit tests pass but it fails in production means you know exactly what kind of test to write next: one that replicates the issue in production. Unit tests are quicker to run which makes iteration easier. Integration tests take longer to execute. They both have their strengths and weaknesses.
2 comments

Out of curiosity, how long do integration tests take to run for you? I will run e.g. "pytest", which might take a few minutes with a lot of integration tests, but I can also just run "pytest -k test_something" to run a particular integration test that will hit the function I care about, and it will take maybe 20 seconds. Unit tests are faster than that, yeah, but honestly that's a tight enough feedback loop for me to iterate quickly.
On my personal project with 78 integration tests it takes about 2.5min. Test coverage isn't anywhere near complete. I can target individual tests too, but I'm usually testing in browser locally anyway so its the rest of the suite that needs to run to find the unexpected regressions.
Author here, love this comment. Wish I would've wrote more about this loop (thing breaks in production, writing a test so said thing wont break again).

I really wish their was a way to make integration tests run quickly.