[ Web Proxy ]
URL:
Viewing: https://developer.android.com/reference/android/support/annotation/VisibleForTesting [Back]  [Original]

VisibleForTesting  |  API reference  |  Android Developers Skip to main content
Essentials Design & Plan Develop Google Play Blog
Search:
Android Studio
Android Developers [Android Developers]
Stay organized with collections Save and categorize content based on your preferences.

VisibleForTesting

public abstract @interface VisibleForTesting
implements Annotation

android.support.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

disclosure_down.png [disclosure_down.png] From interface java.lang.annotation.Annotation
abstract Class<? extends Annotation> annotationType()
abstract boolean equals(Object arg0)
abstract int hashCode()
abstract String toString()

Constants

NONE

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

int PACKAGE_PRIVATE

The annotated element would have "package private" visibility

Constant Value: 3 (0x00000003)

PRIVATE

int PRIVATE

The annotated element would have "private" visibility

Constant Value: 2 (0x00000002)

PROTECTED

int PROTECTED

The annotated element would have "protected" visibility

Constant Value: 4 (0x00000004)

Public methods

otherwise

int otherwise ()

The visibility the annotated element would have if it did not need to be made visible for testing.

Returns
int

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2025-02-10 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page