visibleForTesting top-level constant

_VisibleForTesting const visibleForTesting

Used to annotate a declaration that was made public, so that it is more visible than otherwise necessary, to make code testable.

Tools, such as the analyzer, can provide feedback if

  • the annotation is associated with a declaration not in the lib folder of a package, or a private declaration, or a declaration in an unnamed static extension, or
  • the declaration is referenced outside of its defining library or a library which is in the test folder of the defining package.

Implementation

const _VisibleForTesting visibleForTesting = _VisibleForTesting();