Write stateful properties
Import the library
To perform stateful testing, in addition to importing kiri_check/kiri_check.dart, you need to import kiri_check/stateful_test.dart.
Example:
import 'package:kiri_check/kiri_check.dart';
import 'package:kiri_check/stateful_test.dart';Write process
The stateful testing process is divided into three steps: preparing the model and the real system, defining the Behavior class, and executing it.
Implement the model and the real system
To perform stateful testing, first prepare the code for the model and the real system. The model serves as a reference for comparison with the real system. There are no specific classes that need to be inherited, so feel free to implement them as you like.
Define the Behavior
Define a
Behaviorclass and specify the test content. Specifically, include the following three elements:- Generate the model and the real system: The
initialStatemethod generates the abstract model, and thecreateSystemmethod generates the real system using that model. These objects represent the initial state of the test. - Terminate the real system: Override the
destroySystemmethod to describe the termination process of the real system at the end of the test. - Define the commands to be executed randomly: The
generateCommandsmethod generates a list of commands that will be executed randomly during the test.
- Generate the model and the real system: The
Execute the Behavior
Execute the defined
Behavior. Use therunBehaviorfunction to start the test.
For specific examples, refer to the Quickstart.