In case the tests are in a different module than the production code (which is common), what's the best way to make internal functions visible for tests?
In Java, I would have the production code and the test in the same package and make the methods-to-be-tested package-private (plus, add a @VisibleForTest
annotation if the only reason for having it package-private rather than private is the test). Unfortunately, Kotlin doesn't have the concept of package-private.
Classes and methods marked with
internal
access modifier will work from within current versions of Kotlin, Gradle and also Intellij for accessing those methods from test classes. The tools consider the main and test source paths as part of the same module.Did you try this already? And if it failed you should report a bug since this was already reported, fixed and should be fine in any current version.