@VisibleForTesting
protected void doSomething() {
// ...
}
I never knew there was such an annotation. Well, I think it's easier to understand at a glance, "Why is it protected?" If it's a project that uses guava, it might be a good idea to try it.
By the way, package private has a narrower disclosure range than protected, so it may be safer to keep it package private. (I think I wrote it in the introduction to Junit practice ...)
When I search on GitHub, it looks like an annotation that is used as it is. Some projects in Kotlin also have Visible For Testing.
com.google.common.annotations Visible For Testing is the only one that seems to be usable in business.
I wrote Java for the first time in a few years, and I learned a lot, so I made a note of it. Maybe if you are a person who writes Android apps on a daily basis, is it a common sense level?
Recommended Posts