Hi @felangel
I am not able to figure it out what below error wants to say
========================================================
package:test_api expectLater
package:flutter_test/src/widget_tester.dart 233:10 expectLater
testcomcureambit\mobile\bloc\otp\otp_bloc_test.dart 18:5 main.
Expected:
Actual:
==========================================================
Even though both expected and actual are similar then too this is failing.
can you please help me to figure it out why is it failing????
bloc code
```import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:root/com/cureambit/mobile/service/otp_service.dart';
import './bloc.dart';
class OTPBloc extends Bloc
final OTPRepository _otpRepository;
OTPBloc(this._otpRepository);
@override
OtpBlocState get initialState => OTPTimerInitialise();
@override
Stream
OtpBlocEvent event,
) async* {
if (event is TimerCompleted) {
yield OTPResendInitialise();
}
if (event is ResendOTP) {
yield OTPTimerInitialise();
await Future.delayed(Duration(seconds: 2));
}
if (event is OTPSubmission) {
bool isValidOtp = await _otpRepository.validateOTP(event.otpValue);
if (!isValidOtp) {
yield OTPFailure();
} else {
yield OTPSuccess();
}
}
}
}
**test code**
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:root/com/cureambit/mobile/bloc/otp/bloc.dart';
import 'package:root/com/cureambit/mobile/service/otp_service.dart';
class OTPRepositoryMock extends Mock implements OTPRepository {}
void main() {
OTPRepositoryMock _otpRepository;
OTPBloc _otpBloc;
setUp(() {
_otpRepository = OTPRepositoryMock();
_otpBloc = OTPBloc(_otpRepository);
});
test("Initial state should be 'OTPTimerInitialise'", () {
expectLater(
_otpBloc.initialState,
OTPTimerInitialise(),
);
});
test('dispose does not emit new states', () {
expectLater(
_otpBloc.state, emitsInOrder([OTPTimerInitialise(), emitsDone]));
_otpBloc.dispose();
});
}
```
both the test cases are failing.
Hi @JONA-Cureambit 馃憢
Thanks for opening an issue!
Is your OtpBlocState extending Equatable or overriding == and hashCode? If not then you need to make that change in order to assert that two different instances of the object are equal.
Let me know if that helps 馃憤
Hi @felangel
Thank you this got resolved :)
Most helpful comment
Hi @felangel
Thank you this got resolved :)