Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Recently Inherited a code base with almost 20000 tests. Many very detailed. Most of them were so mocked out that at end of day it was just ensuring the mock library was well tested.


> Most of them were so mocked out that at end of day it was just ensuring the mock library was well tested.

But what's the alternative here, when your code depends on other services and other logic that might return complex data structures, or need to do dozens of database calls?

Should you go for primarily integration tests, which might not only slow everything down, but also force you to think about the possibility of either needing to mirror your current environment per test run (e.g. launch a database, run all the migrations, generate needed test data, launch your app against the database instance, run tests against it, clean everything up), or being limited to a single test run at a time with no parallelism?


It depends on the codebase I think, some codebases are spaghetti mess that really benefit from being well integration tested. Other codebases are really well organized, atomic and have really clearly separated concerns. I think you can afford to run smaller less integrated unit tests. I don't think there's a right or wrong answer, just a balance of the two depending on your project.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: