4 ms·
Why?
by bluepizza 5y ago
Why?
- ipaddr 5y agoBecause he has reached a conclusion. Anything further can be safely ignored if it doesn't fit that conclusion. Never let someone tell you what unit tests are.
- tuxie_ 5y agoHi, I don't really understand who do you refer to when you say that "anything further can be safely ignored". By me? What exactly can be ignored? Sorry, I would like to answer your comment since it seems that it upset you, and nothing was further from my intention. But I honestly don't understand what you mean.
- tuxie_ 5y agoHey bluepizza. As I wrote in response to another comment, I think that too much mocking (and/or mocking in the wrong places) is a code smell. I was not aiming to define what a unit test is, more like when it stops being a unit test, and I think that if you have to mock, for example, a DB call inside your business logic, well you are writing an integration test at that point, whether or not you mock the DB out. If you design your code so that you only have those dependencies at the edge of the system then you get, in my opinion, a much cleaner design and much more testable code.
- bluepizza 5y agoBut if you include a real DB on your business logic testing, that's not unit testing anymore, is it,
- tuxie_ 5y agoExactly. It may sound ridiculous but it happens all the time. You dig into the "unit tests" of the app and you find mocks for a db call, or an API call, or the system's date, or environment variables that some other part of the system will break if they are not defined (or all of the above). That's what I mean, these are all code smells that the code is highly coupled.