Package com.tomtom.ivi.platform.tools.api.testing.unit

Types

Link copied to clipboard
abstract class IviTestCase : TtTestCase

Base class for unit tests that depend on the TomTom Digital Cockpit platform.

Link copied to clipboard
class MockkRetryTestRule(maxTries: Int = MAX_RETRIES_COUNT_DEFAULT) : TestRule

TestRule to work around mockk problem that causes intermittent failures of tests with mocked lambdas.

Properties

Link copied to clipboard
val AnyIviServiceBase.isReady: Boolean

Returns whether or not a tested service instance is marked as ready, allowing it to be available to clients.

Functions

Link copied to clipboard
@ExperimentalCoroutinesApi
fun TestCoroutineDispatcher.advanceTimeByDeprecated(delayTimeMillis: Long): Long

Moves the Dispatcher's virtual clock forward by delayTimeMillis. The amount the clock is progressed may be larger than the requested delayTimeMillis if the code under test uses blocking coroutines. The virtual clock time will advance once for each delay resumed until the next delay exceeds the requested delayTimeMills.

@ExperimentalCoroutinesApi
fun TestCoroutineScope.advanceTimeByDeprecated(delayTimeMillis: Long)

Advances the testScheduler by delayTimeMillis and runs the tasks up to that moment (inclusive).

Link copied to clipboard
@ExperimentalCoroutinesApi
fun TestCoroutineDispatcher.advanceUntilIdleDeprecated(): Long

Immediately execute all pending tasks and advance the virtual clock-time to the last delay. If new tasks are scheduled due to advancing virtual time, they will be executed beforek advanceUntilIdle returns. Returns the amount of delay-time that this Dispatcher's clock has been forwarded in milliseconds.

@ExperimentalCoroutinesApi
fun TestCoroutineScope.advanceUntilIdleDeprecated()

Advances the testScheduler to the point where there are no tasks remaining.

Link copied to clipboard
fun <T, B, V> MockKAnswerScope<T, B>.iviServiceFunResult(value: V)

Short hand to answer an IVI service function with a successful result code and return value.

fun <T, B, V> MockKAnswerScope<T, B>.iviServiceFunResult(resultType: IviServiceFunResult.ResultType, exception: Exception? = null)

Short hand to answer an IVI service function with a failure result code and optional exception.

Link copied to clipboard
fun parametersProduct(vararg lists: List<*>): List<Array<*>>

Calculates a cartesian product of parameters for ParameterizedRobolectricTestRunner.

Link copied to clipboard
@ExperimentalCoroutinesApi
fun TestCoroutineDispatcher.pauseDispatcherDeprecated()
@ExperimentalCoroutinesApi
fun TestCoroutineScope.pauseDispatcherDeprecated()

Pause the dispatcher. When paused, the dispatcher will not execute any coroutines automatically, and you must call runCurrentDeprecated or advanceTimeByDeprecated, or advanceUntilIdleDeprecated to execute coroutines.

Link copied to clipboard
@ExperimentalCoroutinesApi
fun TestCoroutineDispatcher.resumeDispatcherDeprecated()

Resume the dispatcher from a paused state. Resumed dispatchers will automatically progress through all coroutines scheduled at the current time. To advance time and execute coroutines scheduled in the future use, one of advanceTimeByDeprecated, or advanceUntilIdleDeprecated.

Link copied to clipboard
@ExperimentalCoroutinesApi
fun TestCoroutineDispatcher.runBlockingTestDeprecated(block: suspend TestCoroutineScope.() -> Unit)

Convenience method for calling runBlockingTest on an existing TestCoroutineDispatcher.

@ExperimentalCoroutinesApi
fun runBlockingTestDeprecated(context: CoroutineContext = EmptyCoroutineContext, testBody: suspend TestCoroutineScope.() -> Unit)

Executes a testBody inside an immediate execution dispatcher. If context contains CoroutineDispatcher or CoroutineExceptionHandler, then they must implement DelayController and TestCoroutineExceptionHandler respectively. This is similar to runBlocking but it will immediately progress past delays and into launch and async blocks. You can use this to write tests that execute in the presence of calls to delay without causing your test to take extra time.

Link copied to clipboard
@ExperimentalCoroutinesApi
fun TestCoroutineDispatcher.runCurrentDeprecated()

Runs the tasks that are scheduled to execute at this moment of virtual time.

@ExperimentalCoroutinesApi
fun TestCoroutineScope.runCurrentDeprecated()

Run any tasks that are pending at the current virtual time, according to the testScheduler.