3 ms·
I find unit tests to be useful for testing complex and stateless logic but not much else (which is most things). Im mystified that they became the "default" te
by pydry 3y ago
I find unit tests to be useful for testing complex and stateless logic but not much else (which is most things).
Im mystified that they became the "default" test. They ought to be niche.
- bluGill 3y agoIf you are writing the standard library for a programing language than unit tests are useful. If you are implementing an algorithm for any other reason you should ask why isn't this in a standard library already. Sometimes your company will have good reasons for making their own standard library, sometimes you will bring in a third party algorithm library. Most coding though isn't making an algorithm it is using existing known algorithms to massage data. As such most code shouldn't be unit tested. If you are making a standard library then you should be writing a lot of unit tests. However odds are that isn't your job.
- Izkata 3y agoThe original argument for unit tests was on semantic units (do a thing) and not code units (a function). The interface could be a class or a set of functions, but the idea was in part not to break it down further than needed or combine separate requirements into one tests. I think code units / syntactic units became popular as a simplification of the original idea, people copying the style from examples and seeing it as a solution to their problems without actually understanding what the example was describing. Then it gets repeated over and over as "test individual functions" until the original idea is lost and most people haven't even heard of it. Nowadays the original idea is partially described by black box testing.
- pydry 3y agoIn which case my playwright tests that hit a local database and send an email to a local SMTP gateway are unit tests.