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

A couple of ways of looking at unit tests:

* a 'journal' - at the date this test was written, this is how we expect the system to behave

* an ELI5 - if I'm trying to use this method, why am I passing all these complex objects?

Unit tests declare expected behaviour, and should make the developer think about their methods.

For example, why pass complex objects to just to print a string or a count or similar? And why pass those objects? could a method be generalised to take a lambda, or an interface instead? Could the method be pure? And so on.

Unit testing isn't overrated, just a bit misunderstood.



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

Search: