Re:Testcontainers
by marginalia_nu on Tuesday February 27, 2024 @07:25PM
(#39532242)
Seems like such a test would be strictly less useful than a test that runs against the real dependeny.
[ Parent
| on HN ]
Then don't do it in unit tests and write an integration test.
Re:Testcontainers
by joshuamorton on Tuesday February 27, 2024 @07:32PM
(#39532309)
But vastly faster.
A good rule of thumb for a unit test is that you should be able to run it a few thousand times in a relatively brief period (think: minutes or less) and it shouldn't ever fail/flake.
If a unit test (suite) takes more than a single digit number of seconds to run, it isn't a unit test. Integration tests are good to have, but unit tests should be really cheap and fundamentally a tool for iterative and interactive development. I should be able to run some of my unit tests on every save, and have them keep pace with my linter.
Re:Testcontainers
by marginalia_nu on Tuesday February 27, 2024 @07:42PM
(#39532386)
Testcontainers don't typically add more than a few seconds to a suite though. They are very fast.