@Retention(value=CLASS)
public @interface VisibleForTesting
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.PROTECTED)
public String printDiagnostics() { ... }
If not specified, the intended visibility is assumed to be private.Modifier and Type | Fields and Description |
---|---|
static int |
NONE
The annotated element should never be called from production code, only from tests.
|
static int |
PACKAGE_PRIVATE
The annotated element would have "package private" visibility
|
static int |
PRIVATE
The annotated element would have "private" visibility
|
static int |
PROTECTED
The annotated element would have "protected" visibility
|
Modifier and Type | Optional Element and Description |
---|---|
int |
otherwise
The visibility the annotated element would have if it did not need to be made visible for
testing.
|
public static final int PRIVATE
public static final int PACKAGE_PRIVATE