#5 - BLoC Testing - Why do you hate testing? It's actually pretty amazing!

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ก.ย. 2020
  • Hi there!
    Today I'll try to explain you why hating testing inside flutter and inside any other app is kind of a big mistake and I'll try to make sure you understand why your development workflow will get easier if you wisely use tests to double check that everything works fine inside your app. Enjoy!
    The link to the folders you need to clone to get the project files (#3 - Bloc Concepts Counter App) -
    github.com/TheWCKD/blocFromZe...
    All animations were done in VideoScribe, you can try it by clicking my affiliate link --- www.awin1.com/cread.php?awinm...
    You can contact me directly here:
    Join my Discord Server --- / discord
    Twitter --- / letsgetwckd
    Instagram --- / letsgetwckd
    Also, if you want to support me furthermore you can become an TH-cam Member, donate or buy my courses on Udemy, using the following links:
    Become an Official TH-cam Member! ---- / flutterly
    Buy my Udemy Courses! ---- www.udemy.com/user/tiberiu-po...
    Support me on Revolut! ---- revolut.me/letsgetwckd
    Buy me a Ko-fi! --- ko-fi.com/wckdyt
    Donate me on Paypal! --- www.paypal.me/letsgetwckd
    Support me on Patreon! --- / wckdyt

ความคิดเห็น • 88

  • @Flutterly
    @Flutterly  3 ปีที่แล้ว +2

    Hello, everyone!
    The entire course is now live on Udemy too, get it while it's hot --> www.udemy.com/course/bloc-from-zero-to-hero/?referralCode=E689592633984B34DBEF
    Also I have just managed to finally finish the entire BLoC - From Zero to Hero Complete Course, based on this tutorial series. You can check it out here -> th-cam.com/video/THCkkQ-V1-8/w-d-xo.html

  • @R3d_Devil
    @R3d_Devil 3 ปีที่แล้ว +20

    I thought I was familiar with bloc but these tutorial series of yours has taught me a lot. Thank You!

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว +1

      This means a lot to me, mate! Thanks a lot!

  • @poomchantarapornrat5685
    @poomchantarapornrat5685 3 ปีที่แล้ว +9

    AMAZING tutorial. Teaching me "why" before "how" makes me know what to expect to get from this topic.

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว +1

      I really appreciate it! You're welcome!

  • @skypuff
    @skypuff ปีที่แล้ว +2

    This is timeless.
    I'm now following this series. It's been a couple of years since its release and everything so far still works the same.

  • @TreyHope
    @TreyHope 3 ปีที่แล้ว +4

    Never wrote a bloc test before but now I see how vital it is. Thank you for the solid explanation!

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว

      Thank you so much! ✨ Glad I could help!

  • @JulianaPassos
    @JulianaPassos 3 ปีที่แล้ว +8

    This series is being extremely helpful to my development in BLOC. Your explanation is so clear and direct. Specially about the importance of equatable to trick Dart to compare the instances by value and not by place in memory. I'm happy to be one of the first ones to "discover this channel" and I'm doing each tutorial on the same day that you release them. PRECIOUS material. Thanks so much!

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว

      Thank you so much for your kind words! Glad I could help!

  • @jayefoucher9586
    @jayefoucher9586 ปีที่แล้ว +1

    I seriously cannot thank you enough for these extremely informative, well explained, and BEAUTIFULLY ANIMATED lectures!!!

  • @efmuzyka
    @efmuzyka 2 ปีที่แล้ว +6

    With new version of bloc_test, this is crucial to add types in method: blocTest()

  • @filippalexandrov1554
    @filippalexandrov1554 ปีที่แล้ว

    I normally only write hateful comments, but your tutorials are so amazingly helpful in both theoretical and practical ways, that i had to say Thanks!

  • @eikeimnetz
    @eikeimnetz 2 ปีที่แล้ว +8

    null-safety Update:
    hi folks, i struggled a bit with the Flutter Update that brings null-safety with it.
    Here is how it works for me in 04/2022
    just to be complete, here are the pub.dev packages I used:
    *** pubspec.yaml ***
    dependencies:
    flutter:
    sdk: flutter
    cupertino_icons: ^1.0.4
    flutter_bloc: ^8.0.1
    bloc_test: ^9.0.3
    equatable: ^2.0.3
    dev_dependencies:
    flutter_test:
    sdk: flutter
    flutter_lints: ^1.0.4
    I first made the 'wasIncremented' boolean optional by added an '?' after bool
    *** counter_state.dart ***
    part of 'counter_cubit.dart'';
    class CounterState extends Equatable {
    int counterValue;
    bool? wasIncremented;
    CounterState({
    required this.counterValue,
    this.wasIncremented
    });
    @override
    List get props => [counterValue, wasIncremented];
    }
    *** counter_cubit.dart ***
    import 'package:bloc/bloc.dart';
    import 'package:equatable/equatable.dart';
    part 'counter_state.dart';
    class CounterCubit extends Cubit {
    CounterCubit() : super(CounterState(counterValue: 0));
    void increment() => emit(CounterState(counterValue: state.counterValue + 1, wasIncremented: true));
    void decrement() => emit(CounterState(counterValue: state.counterValue - 1, wasIncremented: false));
    }
    lastly i edited the test file to my needs, the most important things were commented by others here: changing
    act: (cubit) => cubit.decrement(),
    to
    act: (CounterCubit cubit) => cubit.increment(),
    and changing
    expect: [CounterState(counterValue: 1,wasIncremented: true)],
    to
    expect: () => [CounterState(counterValue: 1,wasIncremented: true)],
    here you see the endresult for the file
    *** counter_cubit_test.dart ***
    import 'package:bloc_test/bloc_test.dart';
    import 'package:bloctest/bloc/counter_cubit.dart';
    import 'package:flutter_test/flutter_test.dart';
    void main() {
    group('CounterCubit', (){
    late CounterCubit counterCubit;
    setUp(() {
    counterCubit = CounterCubit();
    });
    tearDown((){
    counterCubit.close();
    });
    test('der initiale Status ist CounterState(counterValue:0)', (){
    expect(counterCubit.state, CounterState(counterValue: 0));
    });
    blocTest(
    'Das Cubit soll den Status CounterState(counterValue:1,wasIncremented: true) emittieren,'
    'wenn die cubit.increment() Funktion aufgerufen wird',
    build: () => counterCubit,
    act: (CounterCubit cubit) => cubit.increment(),
    expect: () => [CounterState(counterValue: 1,wasIncremented: true)],
    );
    blocTest(
    'Das Cubit soll den Status CounterState(counterValue:-1,wasIncremented: false) emittieren,'
    'wenn die cubit.decrement() Funktion aufgerufen wird',
    build: () => counterCubit,
    act: (cubit) => cubit.decrement(),
    expect: () => [CounterState(counterValue: -1,wasIncremented: false)],
    );
    });
    }

  • @Dilipkumar-yi1zn
    @Dilipkumar-yi1zn ปีที่แล้ว

    Aswome explanation and visual representations. Thank you and best wishes

  • @OCTsecond
    @OCTsecond 3 ปีที่แล้ว +1

    Your videos always clear and easy to understand, help me a lot in the path of learning flutter development!

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว

      Thank you so much! ✨ Glad to hear that!

  • @alisampson6639
    @alisampson6639 2 ปีที่แล้ว +1

    After scouting for tutorials on bloc, just the 3 first videos makes me understand how bloc is simple to understand. Best BLOC patter tutorial ever. Thank u so much sir🥰🥰

  • @rounaktadvi4950
    @rounaktadvi4950 3 ปีที่แล้ว +2

    Buddy, I appreciate the work you are doing by making a proper series of bloc.I'm getting to learn a lot from your channel.I hope you won't stop making such amazing videos for the aspiring flutter devs.Thank you for this series👍🏻

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว

      I won't stop for sure! Thank you for your feedback! ♥

  • @xutopia
    @xutopia 8 หลายเดือนก่อน

    I would hit the like on this video twice if I could. Testing is underrated in the industry.

  • @AhumadaMauricio
    @AhumadaMauricio ปีที่แล้ว

    This series of videos has been so far, very helpful. I want to also point out that, even when you are obviously a non native english speaker, your english is totally understandable even to a non native english speaker like me. Congratulations on your excellent tutorial.

  • @somedevstuff5060
    @somedevstuff5060 3 ปีที่แล้ว +4

    Great content, looking forward to more videos! Keep it up

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว +2

      Thank you so much! Next video will come tomorrow or perhaps on Monday.

  • @samsonnwokike9897
    @samsonnwokike9897 3 ปีที่แล้ว +3

    Awesome videos. I can't wait to learn more from you.

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว

      Thank you so much, man!

  • @CleisonArenhart
    @CleisonArenhart ปีที่แล้ว

    This tutorial is amazing. Thank you so much

  • @shinigami4228
    @shinigami4228 11 หลายเดือนก่อน

    As a 2 year Flutter developer, I was always afraid of Bloc because so many tutorials made it look too complicated. That's why I always preferred riverpod and provider, now I can better understand your video series. Thank you buddy

  • @aryanchauhan6671
    @aryanchauhan6671 2 ปีที่แล้ว

    Awesome video bro. Thanks a lot !

  • @MSemih-dk6xp
    @MSemih-dk6xp 2 ปีที่แล้ว

    Thanks man. Appreciated a lot!!

  • @-RimuruTempest
    @-RimuruTempest 3 ปีที่แล้ว +1

    You are the only one to make sense that why we should use equatable ❤️❤️❤️

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว +1

      Thank you so much! ✨

  • @kentamammadli8009
    @kentamammadli8009 3 ปีที่แล้ว +2

    Amazing tutorial, you are one of the best.

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว +1

      Thank you, man! ✨

  • @diogosequeira4873
    @diogosequeira4873 3 ปีที่แล้ว +1

    Nice! Thank you once again!

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว

      You're welcome!

  • @Hasan-po6ud
    @Hasan-po6ud ปีที่แล้ว

    Thanks

  • @R0cky0
    @R0cky0 10 หลายเดือนก่อน +1

    Great tutorial, Sir. I wonder what theme you are using to display the tree structure within the code as of 3:50? Or any folk knows? Thanks a million!

  • @dev_shaiful
    @dev_shaiful 7 หลายเดือนก่อน

    Super

  • @user-nq5go7xt8o
    @user-nq5go7xt8o 3 ปีที่แล้ว +1

    man you are the best

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว

      Thank you, ma man!

  • @charlesarieschang4317
    @charlesarieschang4317 2 หลายเดือนก่อน

    what are your vscode extensions for the broken lines to see nesting?

  • @swostikgautam5836
    @swostikgautam5836 3 ปีที่แล้ว +1

    bro it would be vey helpful if you make tutorials like
    1. Login with tokens and parse data from public api using bloc
    2. How to use new firebase update on authentication and retrieving data from firebase using boc
    3. And packages like freezed, get_it etc etc...
    you will have my life long gratitude if you get time to make these videos
    anyway thanks for all explanation bro,,,I hope your channel blows...no one have made videos like this

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว

      Sure, will cover everything in future tutorials!

    • @swostikgautam5836
      @swostikgautam5836 3 ปีที่แล้ว

      @@Flutterly thank you bro...looking forward your new videos

  • @davidagyakwa288
    @davidagyakwa288 ปีที่แล้ว

    can there be a longer version or an updated version of this video for bloc

  • @Imheretohelpnhavefun
    @Imheretohelpnhavefun 3 ปีที่แล้ว +1

    Is it safe to just use Equatable on stuff like that? Isn't there a reason for the standard equal signal to compare pointers instead of instance values?
    Great series, by the way, I'm learning a lot

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว

      Yes, of course it's safe. Equatable's only purpose is to make Dart compare objects by value instead of pointers.

  • @leelaitw
    @leelaitw 3 ปีที่แล้ว

    Why the members variables in CounterState automatically change to final itself? around 9:31

  • @amikhan7727
    @amikhan7727 2 ปีที่แล้ว +2

    Hi, I am facing error 10.07 min according to this video,
    error: Expected: CounterState:
    Actual:
    package:test_api

  • @abanahmed4683
    @abanahmed4683 3 ปีที่แล้ว +2

    Man you bloc my mind ❤️! Lol

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว +1

      😂 😂 Haha, I'm bloced

    • @abanahmed4683
      @abanahmed4683 3 ปีที่แล้ว

      😂❤️

  • @fr1day1700
    @fr1day1700 2 ปีที่แล้ว

    So im trying to follow this with the new version of test and equatable .... its not working, null safety stuff is throwing me off. Is this not valid anymore for 2021?

  • @EmilianoKalafatic
    @EmilianoKalafatic 3 ปีที่แล้ว

    I don't understand what's happening but flutter don't recognize the import from equatable, test and bloc_test

  • @juansanmiguel
    @juansanmiguel 3 ปีที่แล้ว +1

    Hi WCKD! I am loving this course but I am having an issue with blocTest. I am getting this error when I try to test the increment and decrement functions.
    The argument type 'List' can't be assigned to the parameter type 'dynamic Function()'.
    Maybe you can help me?

    • @louis-mariemmd3918
      @louis-mariemmd3918 3 ปีที่แล้ว +4

      You need to add () =>
      like that :
      expect: () => [CounterState(counterValue: 1,wasIncremented: true)],

    • @kawsarmoqadsa5990
      @kawsarmoqadsa5990 9 หลายเดือนก่อน

      omg!! thank you, i have benn looking everywhere trying to find the solution to the error.
      @@louis-mariemmd3918

  • @quicksketch1617
    @quicksketch1617 3 ปีที่แล้ว +1

    There is a way to compare without equatable? Always has to use equatable to test?

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว +1

      Check out my latest tutorial #10. You'll find out

  • @lauchiebeans
    @lauchiebeans 3 ปีที่แล้ว

    I see you hearted my comment on your previous video, does that mean what I think it does and we might see an android video on the main channel o_O? Or am I just speculating haha.

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว +2

      Unfortunately no, I don't have time for that anymore, mate. Sorry to disappoint you. Maybe in the future 🔮

    • @lauchiebeans
      @lauchiebeans 3 ปีที่แล้ว

      @@Flutterly A man can dream.

  • @raul286162
    @raul286162 3 ปีที่แล้ว

    I got it, the importantance now. But don't understand yet if i need really make a mirror folder of my lib, I mean if I have pages, blocs, repositores, all together making a total of 65 dart. archives, do I must create 65 test archives?

    • @Kolano666
      @Kolano666 3 ปีที่แล้ว +3

      What he did by separating each test to corresponding folder and placing tests inside is just a suggestion of one possible sollution to test management. You can align them like you want inside test folder as long as it makes sense and is easly readable. The very important thing about tests is that you have to know the measure and not test literally everything because some things are too shallow to test them. Somone can say that its best to have everything covered but in reality you not gonna test every widget if its opening after clicking every possible button inside app but rather important businnes logic of application f.e will app react propertly to various responses from REST API etc. If you are learning test everything and after time you will recognize what is worth testing.

    • @raul286162
      @raul286162 3 ปีที่แล้ว

      @@Kolano666 thank you very much, I really glad you made this summary since I'm new in testing i need to have an overview.

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว

      Thank you for this extremely helpful reply!

  • @delmontee
    @delmontee 5 หลายเดือนก่อน

    The test section using the code provided no longer works, readDown and the test functions have errors :(

  • @erikaszabo1439
    @erikaszabo1439 3 ปีที่แล้ว +2

    I have an error in blocTest( .... act: (cubit) => cubit.increment(), .... )
    The method 'increment' can't be unconditionally invoked because the receiver can be 'null'. What's the problem? Couldn't figure out.

    • @erikaszabo1439
      @erikaszabo1439 3 ปีที่แล้ว +4

      nvm. I changed it to: act: (CounterCubit cubit) => cubit.increment() , and now it recognises the increment function

    • @KuroManX
      @KuroManX 2 ปีที่แล้ว

      @@erikaszabo1439 you saved my life!

  • @keithbacalso9433
    @keithbacalso9433 2 ปีที่แล้ว

    I still do not understand why we still need to test even tho the code is now working.. I mean do we have to test everytime there is a variable it may be String, int, List, AnimationController, blabla controller, and all other variables to mention.... When do we test??? I am so confuse.... do we test only if there are events or actions like increment and decrement?? when?

    • @rohitsrao
      @rohitsrao 2 ปีที่แล้ว

      You build a test suite to give you confidence later that when you implemented a new feature or refactored your code, you haven't accidentally broken something elsewhere.

  • @Add0w
    @Add0w 3 ปีที่แล้ว +1

    Every nice channel I discover has this problem they don't continue what they started.

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว

      What do you mean? What didn't I continue?

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว

      If you're referring to the fact that I didn't post in a long time, I was too busy talking an exam and didn't have the time to do the next video. It takes almost a week straight to do a video like this.

    • @Add0w
      @Add0w 3 ปีที่แล้ว

      @@Flutterly sorry I didn't mean it to you personally but there are other chanels started explaining flutter very nicely and was enjoying watching and liking their videos but ended up a months without videos.

    • @Flutterly
      @Flutterly  3 ปีที่แล้ว

      It won't be true in my case. It was just that I have other exams to sort out before. Sorry for the inconvenience.

    • @Add0w
      @Add0w 3 ปีที่แล้ว

      @@Flutterly sorry for that comment and thank you.

  • @samelobinna101
    @samelobinna101 8 หลายเดือนก่อน

    this uncalled for anyway,

  • @yaqub3567
    @yaqub3567 2 ปีที่แล้ว

    This way of blocTest isn't working any more

  • @FLUTTER_HUB
    @FLUTTER_HUB 4 หลายเดือนก่อน +4

    any one here from 2024?