testValue
A default implementation that provides the previewValue
to test runs (or liveValue
, if no preview value is implemented), but will trigger a test failure when accessed.
static var testValue: Value { get }
To prevent test failures, explicitly override the dependency in any tests in which it is accessed:
@Test
func featureThatUsesMyDependency() {
withDependencies {
$0.myDependency = .mock // Override dependency
} operation: {
// Test feature with dependency overridden
}
}
You may provide your own default testValue
in your conformance to TestDependencyKey
, which will take precedence over this implementation.