Hacker News new | past | comments | ask | show | jobs | submit login

I only write black box tests that call the outer most entry point (often a request to an endpoint) and then check if the database contains the expected results or if I get the correct response.



Unit tests (true unit tests) are good for corner cases that are very hard, or impossible, to test in such situations.

I once lead a file system driver project. Most of the tests used the real file system. (They tested the driver and some glue code as a "unit.")

But, there were some error conditions (corner cases) that we just couldn't test via a real file system, so those were true unit tests that ran a particular piece of code in isolation.

> I only write black box tests that call the outer most entry point (often a request to an endpoint) and then check if the database contains the expected results or if I get the correct response.

This is the approach I used when I wrote some personal blog software a few months ago. (It was a learning project.) I was extremely happy with the results, but in this case, it was useful because this was mostly a server-side rendered web application: https://github.com/GWBasic/z3/tree/master/test




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: