|
|
|
|
|
by drblast
1915 days ago
|
|
Most of the time I've seen dependency inversion "so we can test" the code is littered with hundreds of single-implementation interfaces and no mocks, or stub mocks that are written just to pass the tests. It doesn't actually test anything. In the case where there are mocks, the unit tests are almost always literally testing "can my programming language call a function and return a result" or "can we store data in a database if the database works?" They are functional tests disguised as unit tests, and are testing only non-production fake functionality. Write functional code instead. Liberally use the compiler and the type system to make mistakes impossible instead of unit testing. Unit tests are for when you can't express something in a way where the compiler and type system will save you from errors. Everything else is a functional or integration test and should be testing the production system, not a mockup of the production system that works differently. Basically, write Haskell programs in whatever language you're working in. Use unit tests as a backstop for when the type system isn't as good as Haskell's. |
|