VisibleForTesting
public
abstract
@interface
VisibleForTesting
implements
Annotation
androidx.annotation.VisibleForTesting |
Denotes that the class, method or field has its visibility relaxed, so that it is more widely visible than otherwise necessary to make code testable.
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.
Summary
Constants | |
---|---|
int |
NONE
The annotated element should never be called from production code, only from tests. |
int |
PACKAGE_PRIVATE
The annotated element would have "package private" visibility |
int |
PRIVATE
The annotated element would have "private" visibility |
int |
PROTECTED
The annotated element would have "protected" visibility |
Public methods | |
---|---|
int
|
otherwise()
The visibility the annotated element would have if it did not need to be made visible for testing. |
Inherited methods | |
---|---|
Constants
NONE
public static final int NONE
The annotated element should never be called from production code, only from tests.
This is equivalent to @RestrictTo.Scope.TESTS
.
Constant Value: 5 (0x00000005)
PACKAGE_PRIVATE
public static final int PACKAGE_PRIVATE
The annotated element would have "package private" visibility
Constant Value: 3 (0x00000003)
PRIVATE
public static final int PRIVATE
The annotated element would have "private" visibility
Constant Value: 2 (0x00000002)
PROTECTED
public static final int PROTECTED
The annotated element would have "protected" visibility
Constant Value: 4 (0x00000004)
Public methods
otherwise
public int otherwise ()
The visibility the annotated element would have if it did not need to be made visible for testing.
Returns | |
---|---|
int |