Unittests can have side effects, most yall will say this is a bug to use but every once in a while Im tempted.
It would mean requiring a user to pass a flag tho and you now are dependent on unit tests passing all the time. Unit tests could be duplicated under another keyword or colored.
File myconfig;
int getconfigdetail(){
assert(myconfig.isopen);
return 3;
}
void main(){
int detail=getconfigdetail();
}
setuptime{//unittest{
myconfig=File(myconfig);
}
unittest{
assert(1==0);
}
In the above code the myconfig file would be properly opened at "unittest time" without passing the -unittest flag and then getting a failing program from the bad unit test. Eliminating the trade offs, and unclear use of the feature.