32 questions
1
vote
1
answer
40
views
Flutter Mocktail : <type 'Future<PermissionStatus>' is not a subtype of type 'Permissions'>
I'm trying to mock the background_downloader package , specifically this line in my class I'm trying to mock:
var status = await fileDownloader.permissions.status(permissionType);
I keep getting error ...
1
vote
1
answer
103
views
Does Flutter Bloc handle multiple rapid event emissions correctly?
I'm working with Flutter Bloc and noticed that when I dispatch the same event multiple times in quick succession, Bloc emits multiple Loading states before transitioning to Success. This behavior ...
2
votes
1
answer
196
views
blocTest error : No method stub was called from within `when()`
I am using mocktail package. I am mocking WeatherRepository . So I don't quite understand what this error is . Please find the below code attached
import 'package:weather_app/data/data_provider/...
1
vote
0
answers
39
views
flutter bloc_test show incorrect expected state
I am having issues with bloc_test, the expected does not match with the code.
**
Expected: [
AuthenticationState:AuthenticationState(RequestStatus.initial,
RequestStatus.loading, RequestStatus....
0
votes
1
answer
564
views
Why state is not updating in bloc_test?
I am new at testing of flutter app, so I am trying to find out how to test it correctly, and now I am confused when I faced this error. When I try to change state in bloc_state testing then state ...
0
votes
1
answer
302
views
Flutter [bloc_test] not throwing a expection
When I want to test my completedIntroTutorial method, I'd like to also test the on Exception catch for that I call inside the unit test thenThrow, but it isn't throwing an exception.
I have tried to ...
3
votes
1
answer
766
views
Flutter bloc test with droppable event
How can I test a bloc event using flutter bloc test that has a droppable (or restartable) event?
Event example:
on<SomeEvent>(
_mapSomeEvent,
transformer: droppable(),
);
I tried calling ...
0
votes
1
answer
522
views
How can I test a future function using bloc test
I'm new to bloc and currently learning bloc testing. The below code is
working fine in debug mode. However, I can't find anything to await the
function to test the current position/error.
Here is my ...
0
votes
1
answer
326
views
Flutter Dartz bloc test argument type not assignable issue
I am writing flutter test method using bloc_test and mockito library. I am getting below strange issue while mocking repository API call. It might be a simple fix but I am trying it since last couple ...
3
votes
2
answers
3k
views
bloc_test: Bad state: Cannot emit new states after calling close
I have a problem in Test section of flutter, I wrote a test for simple counter app which uses cubit, but while I run all test it gives me the error mentioned in header, any body knows why?
it is ...
3
votes
1
answer
2k
views
Flutter: bloc test problem with comparing expected and actual
I have tests like the below:
blocTest(
'emits [ViewData.loading and ViewData.loaded] when GetRepositories is added',
build: () {
when(
() => useCase....
0
votes
0
answers
247
views
Why I'm getting empty actual array from blocTest function?
So I'm implementing blocTesting for my project and I'm getting an empty actual array from a specific feature.
share_bloc_test.dart
Below is the code for the blocFunction that is returning the empty ...
1
vote
1
answer
1k
views
Flutter Bloc Test Problem With Comparing Expected and Actual
I'm trying to create a test case for getting list stores data and I currently fail to implement some working tests but I got some problems when trying to compare the data list.
This is my test's code:
...
0
votes
1
answer
728
views
How to test getters in a state class using bloc_test?
Say I have a state class
class MyState extends Equatable {
final bool isSaving;
final String errorMsg;
const MyState({
this.isSaving = false,
this.errorMsg = '',
});
@override
...
0
votes
1
answer
401
views
Flutter blocTest Missing type arguments for generic function 'blocTest<B extends BlocBase<State>, State>'
When following the bloc test documentation, I created the following blocTest;
blocTest('should do something',
build: () => SignInBloc(signIn: mockSignIn),
act: (bloc) => bloc.add(const ...
1
vote
1
answer
648
views
BloC testing "The method xxx isn't defined for the type 'Object'" error
I am trying to learn testing with bloc. Followed the procedure as stated in docs.
I have lib/cubit/counter_cubit.dart and lib/cubit/counterState.dart files
counter_cubit.dart is:
import 'package:bloc/...
2
votes
1
answer
4k
views
Unit Testing a Cubit
This is my first effort at testing my Cubit class, so please bear with me as I am completely out of ideas after trying for many hours.
I'm trying to test a simple cubit that looks like this:
@...
5
votes
1
answer
3k
views
Bad state: A test tried to use any or captureAny on a parameter of type T State using bloc_test and mocktail
I tried the solutions in here https://github.com/felangel/mocktail/issues/42 but still get error.
This is my code:
class MockUserRepository extends Mock implements UserRepository {}
class ...
0
votes
2
answers
1k
views
Flutter Bloc Unit Test return an empty array
I'm trying to make a unit test using the bloc_test library.
Here are my codes.
Login Cubit
class LoginCubit extends Cubit<LoginState> with HydratedMixin {
final UserRepository _userRepository;
...
7
votes
1
answer
3k
views
Bloc test with Flutter, wait for async action
I have this bloc_test in my Flutter code
blocTest<ProjectsBloc, ProjectsState>(
'emits [ProjectsState.loading(), ProjectsState.succes([])] with empty projects',
build: () => ...
2
votes
1
answer
6k
views
How to do Unit Testing on bloc using blocTest?
I have a bloc that works to get cartItem from orderItem by id and i want to test the bloc, I've read some bloc testing from flutter_bloc but I still don't know how to implement it on my bloc. I want ...
1
vote
1
answer
770
views
bloc test output unexpected result
I'm confused by the results of the test below
the first doesn't pass,
but somehow the second does not
what am I missing?
thank you
void main() {
group('UserAuthenticationCubit', () {
const user ...
1
vote
2
answers
2k
views
Flutter: How can I unit test a Timer used by a Bloc using blocTest?
How can I test a Timer inside a Bloc, using blocTest?
I’m using the bloc library, with freezed to build the state and event objects (might not matter here, but who knows).
So let’s say I have ...
0
votes
1
answer
811
views
Flutter blocTest returning empty 'actual' array
So i have a simple Cubit class that looks like this:
It is ment to change the isClosed value based on the scrollValue of the list, so if user scrolls up, some widget is going to close.
const ...
0
votes
1
answer
2k
views
Flutter: Unit Testing a Cubit issues
I have been trying to set up unit testing for my cubit but bloc test seems to be having issues. Just trying to check the initial state of the values works just fine with regular test but as soon as I ...
2
votes
1
answer
2k
views
Flutter test bloc error type 'Null' is not a subtype of type
I'm testing a bloc method that fetch a list of restaurants fro the api.
here is my code :
import 'package:bloc_test/bloc_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:...
1
vote
0
answers
1k
views
Flutter BLoC Test failures
Currently trying to implement Unit testing for my cubit and am feeling there is a severe lack in documentation for BLoC test online or useful examples. Can anyone explain what I'm doing wrong with ...
1
vote
1
answer
1k
views
how do you test a flutter block that consumes a stream
i have a bloc that listens to a stream for authentication events (listening for firebase user events). my block is;
class AuthenticationBloc
extends Bloc<AuthenticationEvent, ...
2
votes
1
answer
688
views
Flutter Bloc Test : Null check operator used on a null value (null-safety)
I am using flutter_bloc, bloc_test, and bloc_testing to implement testing. But even after I initialize Bloc in Setup the errors say Null check operator used on a null value.
import 'package:bloc_test/...
1
vote
2
answers
783
views
Flutter Bloc test "bloc.add" null safety issue
I have a flutter bloc_test which is failing due to recent upgrades in Flutter involving null safety.
I have the following code
blocTest('get the usecase name',
build: () {
when(() =&...
9
votes
2
answers
5k
views
Dart / Flutter test cubit, problem with comparing expected and actual
I'm working on an app using a WeatherAPI. I currently fail to implement some working tests. I tried to follow ResoCoders Guide (https://resocoder.com/2019/11/29/bloc-test-tutorial-easier-way-to-test-...
9
votes
1
answer
12k
views
How to implement widget tests by using MockBloc?
I'm trying to implement a Widget Test in order to test a login form. This test depends on a bloc which I'm mocking by using MockBloc. However, it throws the following error:
══╡ EXCEPTION CAUGHT BY ...