assertThrows

suspend fun assertThrows(tile: Tile<*>, expectedException: KClass<out Throwable>): Throwable(source)

Asserts that a Tile throws the expected exception when retrieved.

Parameters

tile

The tile to test

expectedException

The exception class that is expected to be thrown

Throws

if the tile does not throw the expected exception

testMosaic.assertThrows(
tile = FailingTile,
expectedException = IllegalStateException::class
)

suspend fun assertThrows(tile: Tile<*>, expectedException: KClass<out Throwable>, message: String): Throwable(source)

Asserts that a Tile throws the expected exception with a custom failure message.

Parameters

tile

The tile to test

expectedException

The exception class that is expected to be thrown

message

The message to include in case of assertion failure

Throws

if the tile does not throw the expected exception

testMosaic.assertThrows(
tile = FailingTile,
expectedException = IllegalStateException::class,
message = "Expected IllegalStateException but got a different exception"
)

suspend fun <K : Any> assertThrows(tile: MultiTile<K, *>, keys: List<K>, expectedException: KClass<out Throwable>): Throwable(source)

Asserts that a MultiTile throws the expected exception when retrieved with the given keys.

Parameters

tile

The tile to test

keys

The list of keys to request from the tile

expectedException

The exception class that is expected to be thrown

Type Parameters

K

The type of keys in the response map

Throws

if the tile does not throw the expected exception

testMosaic.assertThrows(
tile = FailingUserTile,
keys = listOf("user1", "user2"),
expectedException = IllegalStateException::class
)