Hello everyone, I have a question about Kotest; al...
# kotest
Hello everyone, I have a question about Kotest; all the documentation examples use (public) classes, such as
Copy code
class MyTest: SomeSpec({ ... })
But in e.g. vanilla JUnit classes are always recommended to be internal (package private) and I found out that this works as well:
Copy code
internal class MyTest: SomeSpec({ ... })
Is there a reason test classes should be public or can/should they be internal?
Whatever your preference is, there’s no difference for Kotest. I don’t see much value in internal unit tests, unless they test internal classes in which case the compiler complains. Maybe the suggestion for JUnit is package-private because in Java it was easier to just not write the
👍 1
Copy code
Class and method visibility

Test classes, test methods, and lifecycle methods are not required to be public, but they must not be private.

It is generally recommended to omit the public modifier for test classes, test methods, and lifecycle methods unless there is a technical reason for doing so – for example, when a test class is extended by a test class in another package. Another technical reason for making classes and methods public is to simplify testing on the module path when using the Java Module System.
This is in the JUnit docs
So there is no real motivation other than 'just do it this way'
Also note that internal is not equivalent to package-private.
👍 1