How to use VisibleForTesting for pure JUnit tests

According to the Android docs:

You can optionally specify what the visibility should have been if not for testing; this allows tools to catch unintended access from within production code.

Example:

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
public Address getAddress()

Leave a Comment