TestMosaicBuilder
A builder for creating TestMosaic instances with mocked Tile implementations.
This class provides a fluent API for setting up test scenarios by configuring mock tiles with various behaviors. It supports both Tile and MultiTile mocks with different behaviors like success, failure, delays, and custom logic. Inside runTest, use mosaicBuilder to share its TestScope and scheduler.
Basic Usage
val testMosaic = mosaicBuilder()
.withMockTile(MyTile, "test data")
.withFailedTile(OtherTile, RuntimeException("Test error"))
.withDelayedTile(SlowTile, "delayed data", 1000) // 1 second delay
.build()MultiTile Usage
val testMosaic = mosaicBuilder()
.withMockTile(UserTile, mapOf("user1" to user1, "user2" to user2))
.withCustomTile(ProfileTile) { keys ->
// Custom logic based on requested keys
keys.associateWith { key -> createMockProfile(key) }
}
.build()Functions
Builds and returns a configured TestMosaic instance.
Adds a source to the canvas with the specified object.
Adds a source to the canvas with the specified object and qualifier.
Adds a source to the canvas with the specified class and object. Allows for passing in a superclass as the retrieval type.
Adds a source to the canvas using a CanvasKey.
Adds a source to the canvas with the specified class, qualifier, and object.
Adds a mock MultiTile that fails with the specified exception.
Adds a mock Tile that fails with the specified exception.