The idiomatic practice for unit tests seems to be to put unit tests in a “tests” submodule at the end of the file. Ok, sounds good.
But what if you want to unit test private functions/methods? Unless I’ve missed something major, private functions aren’t visible in a submodule, which makes the hard to test.
I’ve considered the following solutions:
- Push private function tests out of the submodule. Seems like the best option.
- Make everything public. Sort of defeats the point scoping.
- Make them doc tests. I don’t want private functions in my documentation, and the code repetition involved is ugly.
Make me long for Euclid’s visibility rules. But is there a better option I’ve missed?