Package 

Annotation VisibleForTesting

  • All Implemented Interfaces:
    java.lang.annotation.Annotation

    @Retention(value = ) 
    public @interface 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.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static int PRIVATE
      public final static int PACKAGE_PRIVATE
      public final static int PROTECTED
      public final static int NONE
    • Method Summary

      Modifier and Type Method Description
      abstract int otherwise() The visibility the annotated element would have if it did not need to be made visible fortesting.
      • Methods inherited from class java.lang.annotation.Annotation

        annotationType, equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • otherwise

         abstract int otherwise()

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