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

The article addresses this: you need to write tests for the fake as well.

I'm not sure I buy this as something that's desirable to have to do, but it should address your concern.



Hmm, if I’m having to write tests for my tests, I feel something has gone wrong in my life ;)


A "fake" isn't a test; it's a real, working implementation of some interface. The only reason we don't use such implementations in production is for some non-functional reason (efficiency, resilience, etc.). For example, if we want a key/value store we might choose Redis for production, but a HashMap is a perfectly good fake (and you can bet that the language/library implementing HashMap has a ton of tests!)


If this leads to having to spend less time on writing tests in total, things have gone right.

These fakes are much less maintenance heavy. As changes to implementation details don't require changes to tests. Hence, whilst you need to write tests for your tests, you spend less time writing tests in total.


A fake is an implementation. The same tests you use on the real implementation also test the fake implementation.




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

Search: