Re:Show HN: Monty, Mongo tinified. MongoDB implemented in Py...
by slver on Sunday May 30, 2021 @10:02AM
(#27333314)
You can’t test the logic without the parts that interpret the logic. Your mock will fail if I change the name of a alias in my query. A database won’t.
Don’t confuse how it’s done with what is done.
Re:Show HN: Monty, Mongo tinified. MongoDB implemented in Py...
by hinkley on Sunday May 30, 2021 @12:29PM
(#27334373)
Don’t confuse functional tests with unit tests. Both are necessary for systems with side effects (ie most systems)
Re:Show HN: Monty, Mongo tinified. MongoDB implemented in Py...
by slver on Sunday May 30, 2021 @02:43PM
(#27335464)
I hope you realize there's a fuzzy line between those, when you have ideal test doubles, that behave like the real thing, but are just configurable in-memory replicas of the dependency.
People get suck a kick out of categorizing their tests, I honestly find that funny.
Can you run it easily before you commit code to a unit, without a dedicated setup? Yes, then it's a unit test to me.
If it was me I wouldn't call it "something" test at all. It's just automated tests. The rest is mostly BS.
It's a common mistake that people think that HTTP implementations can't be unit tested too, but the truth is a bit more complicated. These libraries are essentially a wire protocol and people think of them as 'wire-protocol' instead of 'wire, protocol'. If you think of it instead as a codec with IO, then you write the codec separately and you can fully test the codec without mocking any IO at all.
It's nearly tautological that code that is written to be unit tested can be unit tested, and code that isn't cannot be. And because people want to get their code 'working' and then prove that it works, they are battling uphill to get good tests written, because good tests can't be written. And then some people use this as confirmation bias for why they shouldn't have to write tests.