Java style guide - use @VisibleForTesting for test-only constructors
Bug: None
Change-Id: Ideb862e1c3ef893286f8cdb092088d426f4e44e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4650698
Commit-Queue: Andrew Grieve <[email protected]>
Reviewed-by: Tommy Nyquist <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1165633}
diff --git a/styleguide/java/java.md b/styleguide/java/java.md
index cbcec5f2..1b3de51 100644
--- a/styleguide/java/java.md
+++ b/styleguide/java/java.md
@@ -276,10 +276,11 @@
should be annotated with [`@VisibleForTesting`]. Android Lint will check
that calls from non-test code respect the "otherwise" visibility.
-Symbols with a `ForTesting` suffix should **not** be annotated with
+Symbols with a `ForTesting` suffix **should not** be annotated with
`@VisibleForTesting`. While `otherwise=VisibleForTesting.NONE` exists, it
is redundant given the "ForTesting" suffix and the associated lint check
-is redundant given our trybot check.
+is redundant given our trybot check. You should, however, use it for
+test-only constructors.
[ensure they are removed]: /docs/speed/binary_size/android_binary_size_trybot.md#Added-Symbols-named-ForTest
[`PRESUMBIT.py`]: https://chromium.googlesource.com/chromium/src/+/main/PRESUBMIT.py