💾 Archived View for stack.tilde.cafe › gemlog › 2022-10-09.unit.gmi captured on 2024-07-08 at 23:38:05. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-09-08)
-=-=-=-=-=-=-
gemini://gemini.conman.org/boston/2022/10/08.1
Sean Conner poses this question.
The answer is actually more sensible in C than it was in Smalltalk: a unit is a compilation unit. In C, it is a file.
Any changes to source will require changes to a file. Once a source file is altered, it may screw something up in the resultant binary. Therefore, there should be a unit test to check that the altered unit behaves as expected.
Now, if it's a header, it may alter the behavior of many source units...
The easiest way to think of it in C is: assume make's view of the system.
Makefiles, if constructed as intended, identify units clearly, and all the headers they depend on (unless some coersive tool is used to hide this valuable information in exchange for convenience).
In better languages which allow compiling functions independently, a unit is more of whatever you want it to be...
I've never been able to keep the discipline of unit testing, and think it's kind of a bad idea, especially in more fluid interactive environments early in the project when things are changing.