Skip to content

Suiteopensavvy.prepared.suiteSharedProvider

SharedProvider


A Shared is a lazily-created value that is reused between tests.

Most of the time, PreparedProvider should be preferred to this class. To learn why, see Shared.

Although SharedProvider is conceptually equivalent to PreparedProvider, and can be used to generate multiple Shared instances from the same block in exactly the same way, this is not recommended.

Shared values should only be used when all of these are true:

If these conditions are met, then generating multiple values from the same SharedProvider makes no sense, as it will necessarily return the same value.

This class exists because of its other use-case: capturing the name of the property it is instantiated to, using the `by` keyword. See shared and provideDelegate.

Functions

named


fun named(name: String): Shared<T>

Provides a Shared value instance bound to the given name.

provideDelegate


operator fun provideDelegate(thisRef: Any?, property: KProperty<*>): SharedDelegate<T>

Provides a Shared instance bound to the given property.