3 ms·
I think that the author never understood why unit tests have been introduced. Nowadays, with BDD slowly gaining momentum,unit tests are even more imprescindible
by tigershark 10y ago
I think that the author never understood why unit tests have been introduced. Nowadays, with BDD slowly gaining momentum,unit tests are even more imprescindible and they really do add business value. In the past TDD used correctly added business value, but BDD takes it one step further helping to write more valuable tests. When he speaks about testing all the registers states and all the possible combinations of inputs it is apparent that he is missing the point. The only thing that a well written unit test should accomplish is to make sure that a requirement is implemented correctly. And it must be written while designing the code. When I write some new feature I try to understand the requirements and model them into scenarios. At the same time I start writing the code to implement the feature required that is complete only when the respective scenario is green. During this workflow I change multiple times both the code and the tests and, contrary to what the author experienced, my velocity is not hampered by the tests, but it's actually increased. This happens because I can improve my design thanks to the tests that force me to see the problem from the users point of view. I don't really think that a person that only focuses on writing code without writing any scenarios can really tackle the problem in the best way.
- kevan 10y ago>The only thing that a well written unit test should accomplish is to make sure that a requirement is implemented correctly. A common side effect of writing these tests is discovering missing or conflicting cases. A recent example for me in eCommerce is our algorithm for determining if a particular product can be added to your cart. Things start simple (is it in stock?), but they get complicated really quickly. Is there a dropship vendor with stock? Do we expect to receive more stock in the next 24 hours? Is it discontinued? Clearance? Does it look like we'll run out in the next day and accidentally oversell the stock we have? (realtime inventory is a little fuzzy still). When we unit test the module that handles all of this we don't care about internal state or exhaustive input testing, we care about whether the user sees "In Stock" or "Out of Stock" for the situations we encounter