4 ms·
I started unit testing for the first time several months back. I tried incorporating it into my general workflow Here's an isolated overkill example of how uni
by Kagerjay 8y ago
I started unit testing for the first time several months back. I tried incorporating it into my general workflow
Here's an isolated overkill example of how unit tests should not be done on one of my codepen files (its a javascript calculator). All tests passed but the calculator is partially broken still. I made about 20 unit test case scenarios when in reality it should have been significantly less (~ about 5 given the complexity of the problem)
https://codepen.io/vincentntang/pen/XqNGqv?editors=1100 https://codepen.io/vincentntang/pen/XqNGqv?editors=1100
I ended up getting very little useful feedback on codereview / stackexchange, but this is how I felt about unit-testing in general.
https://codereview.stackexchange.com/questions/193128/shuntyard-javascript-calculator-with-unit-tests https://codereview.stackexchange.com/questions/193128/shunty...
I think unit testing is great in some applications (e.g. working with teams as more things can be missed, where a bug can be exponentially cause issues, systems with larger complexity). Doing it in isolated solo projects is such a waste of time IMO, good commenting / structurally organizing code/ naming conventions suffices here. Most things don't work in a functional way anyways that makes unit-testing easier. E.g hardware calculators don't have logic the way I wrote it in my code above.
Unit testing is OPPURTUNITY COST. For a business to implement this the risks of exponential failure and its demand for risk-mitigation should far outweigh the time and developmental practice of implementing it in your training / management / workflow / toolchain.
...disclaimer: I might have no idea what I'm talking about I'm a fairly inexperienced dev
- marcosdumay 8y agoYou won't get very far without tests. You will notice it, once you start to create larger programs your productivity will decline. That happens even if you use safe languages and verify your code. This article is to be about the kind of test you should use. It's just that unit tests are often not powerful, but always expensive. So, you should use other kinds of tests.