4 ms·
I think the best tool for this is package-private visibility. It's often much easier to write a test if you can poke at the internals a little bit, but it's a
by iainmerrick 5y ago
I think the best tool for this is package-private visibility.
It's often much easier to write a test if you can poke at the internals a little bit, but it's a bad idea to widen your public API just so you can do that.
So, make your internals package-private and put the test code in the same package.
Unfortunately this isn't easy to do in all languages (e.g. Java gets it right, but Kotlin bases visibility on build packages rather than namespaces).