Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 如何在颤振中测试密封状态类?_Unit Testing_Flutter_Bloc_Freezed - Fatal编程技术网

Unit testing 如何在颤振中测试密封状态类?

Unit testing 如何在颤振中测试密封状态类?,unit-testing,flutter,bloc,freezed,Unit Testing,Flutter,Bloc,Freezed,我在我的Flitter应用程序中使用冻结来生成密封的数据类。我需要测试它,我不知道怎么做。有什么想法吗?这是国家: @freezed abstract class LoginState with _$LoginState { const factory LoginState({ @required Email email, @required Password password, @required bool isLoading, @required bool

我在我的Flitter应用程序中使用冻结来生成密封的数据类。我需要测试它,我不知道怎么做。有什么想法吗?这是国家:

@freezed
abstract class LoginState with _$LoginState {
  const factory LoginState({
    @required Email email,
    @required Password password,
    @required bool isLoading,
    @required bool showErrors,
    @required Option<Either<AuthFailure, Unit>> failureOrSuccessOption,
  }) = _LoginState;

  factory LoginState.initial() => LoginState(
        failureOrSuccessOption: none(),
        isLoading: false,
        showErrors: false,
        email: Email(''),
        password: Password(''),
      );
}
我想检查在执行cubit loginMethod时,它是否正确地将加载状态更改为true(在获得结果时),将加载状态更改为false(在获得结果后),但我收到以下错误消息:

Expected: should do the following in order:
          * emit an event that _$_LoginState:<LoginState(email: Value(Left(EmailFailure.empty())), password: Value(Left(PasswordFailure.empty())), isLoading: true, showErrors: false, failureOrSuccessOption: None)>
          * emit an event that _$_LoginState:<LoginState(email: Value(Left(EmailFailure.empty())), password: Value(Left(PasswordFailure.empty())), isLoading: false, showErrors: false, failureOrSuccessOption: None)>
  Actual: _$_LoginState:<LoginState(email: Value(Left(EmailFailure.empty())), password: Value(Left(PasswordFailure.empty())), isLoading: false, showErrors: false, failureOrSuccessOption: None)>
   Which: was not a Stream or a StreamQueue
Expected:应按顺序执行以下操作:
*发出一个$\u LoginState的事件:
*发出一个$\u LoginState的事件:
实际:$\u登录状态:
Which:不是流或流队列
Expected: should do the following in order:
          * emit an event that _$_LoginState:<LoginState(email: Value(Left(EmailFailure.empty())), password: Value(Left(PasswordFailure.empty())), isLoading: true, showErrors: false, failureOrSuccessOption: None)>
          * emit an event that _$_LoginState:<LoginState(email: Value(Left(EmailFailure.empty())), password: Value(Left(PasswordFailure.empty())), isLoading: false, showErrors: false, failureOrSuccessOption: None)>
  Actual: _$_LoginState:<LoginState(email: Value(Left(EmailFailure.empty())), password: Value(Left(PasswordFailure.empty())), isLoading: false, showErrors: false, failureOrSuccessOption: None)>
   Which: was not a Stream or a StreamQueue