Write code which is hard to unit test
testing, unit-testing
Solution
Take a look at Mishko's Guide: Writing Testable Code, introduce as many of these flaws into your code and you'll end up with untestable code.
For example:
- do as much as you can in constructors, start threads, use loops and ifs
- break Law of Demeter by creating long chain of method calls
- use singletons everywhere, never ask for dependencies, look them up in a static provider
- create god classes with 2k lines of code
Problem
In an interview, I was asked the question “How do you make a code hard to be unit tested?” I ended up mumbling something about writing a tightly coupled code. Can anyone please tell me what’s the right answer/ approach for this question?