News for hackers. Stuff that matters.
Re:Questions to ask yourself when writing tests by ancarda on Tuesday January 02, 2018 @02:37AM (#16050489)
I really wish Uncle Bob would provide code examples with his blog posts and videos. I struggle to imagine what my tests would look like if I followed this. Possibly as my tests are so tightly coupled right now that refactoring is actually not possible in some cases.

Does anyone know of explations of this with a more hands-on approach, or is this simply a collection of ideas that can’t really be shown?

Re:Questions to ask yourself when writing tests by ed_blackburn on Tuesday January 02, 2018 @07:10AM (#16051418)
Practical advice? Consider making every type internal. Then open them up to what is strictly required to be public.

Now you are testing the behaviour of your application through its public surface. This reduces the brittleness of your tests because you can change the internal implementation without rewriting your tests. You have higher assurance. It'll also force your hand to enforce invariants and place guard clauses in the right places rather than "everywhere".

If you follow Cockburn's Ports and Adapters approach too, then you can substitute adapters like persistent state, buses, HTTP clients for appropriate in-memory equivalents.

Re:Questions to ask yourself when writing tests by hdi on Tuesday January 02, 2018 @05:10AM (#16051003)
I've been wondering about that for a while.

So far, I've not been able to find any examples of test architecture that follows those principles online or in my day job.

I've also been too lazy to do a side project and explore a more decoupled and scalable test suite. Maybe I should get off my arse and finally do it.

Re:Questions to ask yourself when writing tests by twic on Wednesday January 03, 2018 @02:26PM (#16064193)
If you're writing a web application, i've had a reasonably happy time with tests at the controller level, or perhaps right below. You want an interface where values go in and out that correspond to fairly user-level ideas, but which are still tractable for testing.
Re:Questions to ask yourself when writing tests by spion on Tuesday January 02, 2018 @08:37AM (#16051742)
I think my example captures the spirit of this: https://news.ycombinator.com/item?id=16049441