SubscriptionTestTag

open class SubscriptionTestTag<T>(val tag: String) : TestTag

TestTag implementation for Subscription operations that provides tag-based identification.

This class is used to identify subscriptions for mocking in test and preview environments, particularly when dealing with auto-generated subscription IDs that may change during configuration changes or recompositions.

Unlike SubscriptionId which might use auto-generated values that can change across recompositions, SubscriptionTestTag provides a stable identifier that can be consistently referenced in tests and previews.

Usage example:

// Define a test tag
class UserUpdatesTestTag : SubscriptionTestTag<User>("user-updates")

// Use with test client
testClient.on(UserUpdatesTestTag()) { MutableStateFlow(mockUser) }

// Apply when getting a subscription
val subscription = client.getSubscription(subscriptionKey, Marker.testTag(UserUpdatesTestTag()))

Parameters

T

The type of data that will be received by the subscription

tag

A unique string identifier for this test tag

Constructors

Link copied to clipboard
constructor(tag: String)

Properties

Link copied to clipboard
open override val tag: String

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int