3 ms·
Unit tests in the same file wastes context and makes the whole thing hard to navigate for humans and machines alike.
by wakawaka28 8mo ago
Unit tests in the same file wastes context and makes the whole thing hard to navigate for humans and machines alike.
- dnautics 8mo agonah, the agents jump around files anyways.
- J_Shelby_J 8mo agoI’ve been doing the least amount of unit tests possible and doing debug asserts instead.
- 0x3f 8mo agoNormally I would put as many invariants in the types as possible, then tests cover the rest. I'm curious how you do this/what you use it for though. Would be cool if you had any examples.
- jimbokun 8mo agoIt’s about the best possible documentation.
- wakawaka28 8mo agoIt isn't documentation. It is example code, in the best case. That shit belongs in other files, not in the main file. There is also a reason why literate programming never took off in general. Good luck getting anything done when 80% (conservatively) of the stuff you have to scroll through contributes nothing to the actual execution of the program and might actually be giving you false impressions of how things need to be done.
- g947o 8mo agoI have yet to see a single Rust file where the test comes before source and takes 80% of the file content.
- wakawaka28 8mo agoProbably because all the tests are trivial, and people have the bias to not add all the testing that is needed inline with the code.