> When I look at most unit tests — especially those
> written with JUnit — they are assertions in disguise.
Very often they're assertions not at all in disguise. Python's `unittest`, for example.
I'd always assumed the point was to run these assertions at 'test-time', prior to distribution, and not have that code in the 'real' program.
Besides, most (?) of the time we probably want to fail more gracefully than that. (Okay we could `except AssertionError`, but typically it's going to be better to return something else, or raise and handle a more specific exception.)
>I'd always assumed the point was to run these assertions at 'test-time', prior to distribution, and not have that code in the 'real' program.
That's the point of assertions, as they are usually not included in release mode builds in compiled languages. In Python you could just write an assert function that does nothing if some global "release" variable is set to true.
You only gain something from unit-tests if they test something that can't be equally well tested by writing the assertions into the regular code and running the software with typical input.
I'd always assumed the point was to run these assertions at 'test-time', prior to distribution, and not have that code in the 'real' program.
Besides, most (?) of the time we probably want to fail more gracefully than that. (Okay we could `except AssertionError`, but typically it's going to be better to return something else, or raise and handle a more specific exception.)