visibleForTesting top-level constant

Object const visibleForTesting

Annotation on a public declaration that should only be used in tests.

Used to annotate a declaration that was made public only for tests.

The declaration should not be treated as available, and should not be used outside of testing, and not outside of the declaring package unless explicitly allowed.

The annotation is only intended for declarations that are otherwise publicly available, meaning an accessible declaration in the lib/ folder of a package.

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 a package.

Implementation

const Object visibleForTesting = _VisibleForTesting();