# VisibleForTesting

Summary: [Constants](https://developer.android.com/reference/android/support/annotation/VisibleForTesting#constants) \| [Methods](https://developer.android.com/reference/android/support/annotation/VisibleForTesting#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/support/annotation/VisibleForTesting#inhmethods) \| [\[Expand All\]](https://developer.android.com/reference/android/support/annotation/VisibleForTesting#)  

# VisibleForTesting

| This package is part of the Android [support library](https://developer.android.com/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](https://developer.android.com/jetpack/androidx) which is part of [Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](https://developer.android.com/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class
| mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).


`
public


abstract
@interface
VisibleForTesting
`


`


implements

Annotation


`

|----------------------------------------------|
| android.support.annotation.VisibleForTesting |

<br />

*** ** * ** ***

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.

<br />

## Summary

|                                                                                        ### Constants                                                                                         ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [NONE](https://developer.android.com/reference/android/support/annotation/VisibleForTesting#NONE) The annotated element should never be called from production code, only from tests. |
| `int` | [PACKAGE_PRIVATE](https://developer.android.com/reference/android/support/annotation/VisibleForTesting#PACKAGE_PRIVATE) The annotated element would have "package private" visibility |
| `int` | [PRIVATE](https://developer.android.com/reference/android/support/annotation/VisibleForTesting#PRIVATE) The annotated element would have "private" visibility                         |
| `int` | [PROTECTED](https://developer.android.com/reference/android/support/annotation/VisibleForTesting#PROTECTED) The annotated element would have "protected" visibility                   |

|                                                                                                        ### Public methods                                                                                                        ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` int` | ` `[otherwise](https://developer.android.com/reference/android/support/annotation/VisibleForTesting#otherwise())`() ` The visibility the annotated element would have if it did not need to be made visible for testing. |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/annotation/VisibleForTesting#)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`.

<br />

Constant Value:

5
(0x00000005)


### PACKAGE_PRIVATE

```
int PACKAGE_PRIVATE
```

The annotated element would have "package private" visibility

<br />

Constant Value:

3
(0x00000003)


### PRIVATE

```
int PRIVATE
```

The annotated element would have "private" visibility

<br />

Constant Value:

2
(0x00000002)


### PROTECTED

```
int PROTECTED
```

The annotated element would have "protected" visibility

<br />

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.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

-

  ## Annotations

  - [AnimatorRes](https://developer.android.com/reference/android/support/annotation/AnimatorRes)
  - [AnimRes](https://developer.android.com/reference/android/support/annotation/AnimRes)
  - [AnyRes](https://developer.android.com/reference/android/support/annotation/AnyRes)
  - [AnyThread](https://developer.android.com/reference/android/support/annotation/AnyThread)
  - [ArrayRes](https://developer.android.com/reference/android/support/annotation/ArrayRes)
  - [AttrRes](https://developer.android.com/reference/android/support/annotation/AttrRes)
  - [BinderThread](https://developer.android.com/reference/android/support/annotation/BinderThread)
  - [BoolRes](https://developer.android.com/reference/android/support/annotation/BoolRes)
  - [CallSuper](https://developer.android.com/reference/android/support/annotation/CallSuper)
  - [CheckResult](https://developer.android.com/reference/android/support/annotation/CheckResult)
  - [ColorInt](https://developer.android.com/reference/android/support/annotation/ColorInt)
  - [ColorLong](https://developer.android.com/reference/android/support/annotation/ColorLong)
  - [ColorRes](https://developer.android.com/reference/android/support/annotation/ColorRes)
  - [DimenRes](https://developer.android.com/reference/android/support/annotation/DimenRes)
  - [Dimension](https://developer.android.com/reference/android/support/annotation/Dimension)
  - [DrawableRes](https://developer.android.com/reference/android/support/annotation/DrawableRes)
  - [FloatRange](https://developer.android.com/reference/android/support/annotation/FloatRange)
  - [FontRes](https://developer.android.com/reference/android/support/annotation/FontRes)
  - [FractionRes](https://developer.android.com/reference/android/support/annotation/FractionRes)
  - [GuardedBy](https://developer.android.com/reference/android/support/annotation/GuardedBy)
  - [HalfFloat](https://developer.android.com/reference/android/support/annotation/HalfFloat)
  - [IdRes](https://developer.android.com/reference/android/support/annotation/IdRes)
  - [IntDef](https://developer.android.com/reference/android/support/annotation/IntDef)
  - [IntegerRes](https://developer.android.com/reference/android/support/annotation/IntegerRes)
  - [InterpolatorRes](https://developer.android.com/reference/android/support/annotation/InterpolatorRes)
  - [IntRange](https://developer.android.com/reference/android/support/annotation/IntRange)
  - [Keep](https://developer.android.com/reference/android/support/annotation/Keep)
  - [LayoutRes](https://developer.android.com/reference/android/support/annotation/LayoutRes)
  - [LongDef](https://developer.android.com/reference/android/support/annotation/LongDef)
  - [MainThread](https://developer.android.com/reference/android/support/annotation/MainThread)
  - [MenuRes](https://developer.android.com/reference/android/support/annotation/MenuRes)
  - [NavigationRes](https://developer.android.com/reference/android/support/annotation/NavigationRes)
  - [NonNull](https://developer.android.com/reference/android/support/annotation/NonNull)
  - [Nullable](https://developer.android.com/reference/android/support/annotation/Nullable)
  - [PluralsRes](https://developer.android.com/reference/android/support/annotation/PluralsRes)
  - [Px](https://developer.android.com/reference/android/support/annotation/Px)
  - [RawRes](https://developer.android.com/reference/android/support/annotation/RawRes)
  - [RequiresApi](https://developer.android.com/reference/android/support/annotation/RequiresApi)
  - [RequiresPermission](https://developer.android.com/reference/android/support/annotation/RequiresPermission)
  - [RequiresPermission.Read](https://developer.android.com/reference/android/support/annotation/RequiresPermission.Read)
  - [RequiresPermission.Write](https://developer.android.com/reference/android/support/annotation/RequiresPermission.Write)
  - [RestrictTo](https://developer.android.com/reference/android/support/annotation/RestrictTo)
  - [Size](https://developer.android.com/reference/android/support/annotation/Size)
  - [StringDef](https://developer.android.com/reference/android/support/annotation/StringDef)
  - [StringRes](https://developer.android.com/reference/android/support/annotation/StringRes)
  - [StyleableRes](https://developer.android.com/reference/android/support/annotation/StyleableRes)
  - [StyleRes](https://developer.android.com/reference/android/support/annotation/StyleRes)
  - [TransitionRes](https://developer.android.com/reference/android/support/annotation/TransitionRes)
  - [UiThread](https://developer.android.com/reference/android/support/annotation/UiThread)
  - [VisibleForTesting](https://developer.android.com/reference/android/support/annotation/VisibleForTesting)
  - [WorkerThread](https://developer.android.com/reference/android/support/annotation/WorkerThread)
  - [XmlRes](https://developer.android.com/reference/android/support/annotation/XmlRes)
-

  ## Enums

  - [RestrictTo.Scope](https://developer.android.com/reference/android/support/annotation/RestrictTo.Scope)