3 ms·
> The tests failed to be useful, simply because they were written after the feature was actually implemented! I find after-the-fact asserts, unit tests, and st
by MaulingMonkey 10y ago
> The tests failed to be useful, simply because they were written after the feature was actually implemented!
I find after-the-fact asserts, unit tests, and static analysis still useful:
- I catch incorrectly handled edge cases that I haven't hit "in the wild" yet (although others may have!)
- I think of new edge cases to handle
- I can be more aggressive in future refactoring
- I can be more confident in excluding the code from my bug hunts
Many of the issues I catch this way are the kind of issues that threaten to turn into really nasty heisenbugs - such as the occasional missing mutex lock. After all, all the low hanging fruit was probably caught when testing the feature locally ;)
- emodendroket 10y agoThe other thing is I tend to be kind of exploratory in style and if I have written a bunch of tests I'm more hesitant to change something, even if it isn't really working.
- lisivka 10y agoParent is talking about functional test cases, i.e. something that can be tested manually from command line. Unit tests are not a functional or integrational tests, so yes, unit tests are useful even after functional and integrational tests are written.
- aisofteng 10y agoThe concept of a functional test seems to vary quite a bit more from engineering group to group than your usage indicates. Sometimes, some unit tests border on functional tests and vice versa, the distinction blurring between two adjacent test cases in a unit test suite. And sometimes integration suites end up testing single functionalities at a time, depending on the design and/or requirements of the application, and could reasonably be called functional tests. On my team, I hesitate to emphasize "functional tests" as a standalone group equivalent in semantic distinction to unit and integration tests; the proper scope of a "functional" test is defined, to me, by the way the functionalities of an application were designed and decoupled, which depends on the particular project. (If your organization uses functional requirements and specifications for software design, it's simpler - a functional test verifies a functional requirement. Unfortunately, having functional requirements as a part of the engineering process is significantly rarer than it should be.)
- aisofteng 10y agoI would probably be willing to say that after the fact asserts useful during development should be considered as candidates to be turned into unit test cases, one to one. Few people use asserts, but I don't see why this methodology couldn't be rather effective, given good practices with asserts.