unittest behaviour

H. S. Teoh hsteoh at qfbox.info
Sun Dec 15 10:51:45 UTC 2024


On Sun, Dec 15, 2024 at 08:45:22AM +0000, DLearner via Digitalmars-d-learn wrote:
[...]
> I appreciate this behaviour matches the docs (so not a bug), but is it
> desirable?
> 
> To me, as a test harness, a umittest block should be a completely
> fresh-from-scratch invocation of the code inside the block, and thus
> not depend on the result/effects of any previous unittest.

That's for you, the programmer, to ensure.  Using a static variable
breaks this assumption.  As does a whole bunch of other things you could
do that have side-effects, such as file I/O or network traffic.  So if
you want your code to be unittest-able in an encapsulated way, refactor
it so that it doesn't have side-effects of this kind.


T

-- 
Caffeine underflow. Brain dumped.


More information about the Digitalmars-d-learn mailing list