testRxT<T> function
- @isTest
Defines a test case for a RxT
object.
The testRxT function defines a test case for a specific RxT
object, which represents
a reactive state container. It allows you to set up the initial state, perform actions
on the state, and verify the expected behavior and outcomes.
The testRxT function takes various parameters to configure the test case, such as the
test description, setup and teardown functions, actions to perform on the state, expected
outcomes, and error handling. It uses the test
library from the test
package to define
and run the actual test.
Example usage:
testRxT<int>(
'RxT test case',
build: () => RxT<int>(0),
act: (rx) => rx.value = 10,
expect: () => [10],
);
In the above example, the testRxT function is used to define a test case for an RxT
object
that holds an integer value. The test case sets up the initial state, performs an action by
assigning the value 10 to the state, and expects the state to have the value 10. The test case
is then run using the test
library.
The testRxT function simplifies the testing of reactive state containers, allowing you to define clear and concise test cases that cover different scenarios and behaviors of the state.
Implementation
@isTest
void testRxT<T>(
String description, {
required RxT<T> Function() build,
FutureOr<void> Function()? setUp,
T Function()? seed,
FutureOr<void> Function(RxT<T> rx)? act,
Duration? wait,
int skip = 0,
List<T> Function()? expect,
FutureOr<void> Function(RxT<T> rx)? verify,
Object Function()? errors,
FutureOr<void> Function()? tearDown,
dynamic tags,
}) {
test.test(
description,
() async {
await _rxtTest<T>(
setUp: setUp,
build: build,
seed: seed,
act: act,
wait: wait,
skip: skip,
expect: expect,
verify: verify,
errors: errors,
tearDown: tearDown,
);
},
tags: tags,
);
}