Where do you learn all this TDD style?Do you have any cool resources to practice this TDD style with mocks? Any book similar to your style?, BTW cool videos. Hard to find this kind of content.
the test 'should check if the device is online', wasn't working for me since repository.getConcreteNumberTrivia(tNumber); wasn't mocked with a proper when call adding when(mockRemoteDataSource.getConcreteNumberTrivia(tNumber)).thenAnswer((_) async => tNumberTrivaModel); in the arrange section fixed this
@@gameofcodes9832 Because there was no Null Safety checks in Dart at the time the tutorial was recorded. It means now getConcreteNumberTrivia cannot return Null. Instead you have to provide a mocked value.
I run into an issue with the test 'should return server failure when the call to remote data source is unsuccessful' verifyZeroInteratctions(mockLocalDataSource); returned an error and i had to add reset(mockLocalDataSource) in the arrange part to fix all previous interactions with this mock since it seems not to reset within a test() block. If this is the case every test should start with a cleanup to reset all mocks before doing testing to not rely on the order of the tests.
Hello Matej. 1 year after you publish this amazing series I'm starting to learn Flutter, but I want to do it the right way, by having a very well organized code as I can see clean architecture and TDD can do. I had made a question, but it was my bad, I was coding along with you while watching the video, but I realized I had a mistake.It's already solved so I edited this comment to delete such question. Thanks a lot, and keep it up with your awesome videos buddy! God bless you!
It seems very overwhelming. The whole 'clean' architecture thing. Could you provide a more in-depth series on clean architecture alone without TDD? Or if you could provide me with any easy-to-comprehend resources to follow? Awesome work btw as always thanks.
It's true that doing TDD can be a bit confusing when you're also learning about the overall architecture. I'm yet to find an easy to follow clean architecture resource (except for this course 😉). Just try looking at the diagram from the first part and also notice the dependencies of different classes. This is what really matters with Clean Architecture.
Hi, thank By the way, I am wondering how at 14:42 , expect(result, equals(Right(tNumberTrivia))); can pass the equality test since they are not the same type. At least for me, it says: Expected: Right: Actual: Right: And the test fail even if NumberTriviaModel extends NumberTrivia
Absolutely brilliant, I've been dreaming of an architecture like this since I started object oriented programming. Thank you for this content, I am very grateful.
nice video. But I have some questions. 1) what counts as a feature?(when should I make a new feature) and 2) should I put in the core folder a domain & data ? Thanks
After I finish this series I will start a Flutter App with Firebase. I guess your doubts are pretty close to mine. To listen Firebase data changes passing from the datasource until UI layer. I think that is when Bloc or Provider comes to play. Not sure how yet.
@@ResoCoder WoW!! Really? That would be great. I just started an Flutter App. I stopped due to design architecture issues. That's why I am doing this Flutter TDD course first. The only one I found that really focus on Clean and Tests. I already seem to much spaghetti UI Apps. And I really do not want mine to be like those.
Edit: this was a lot easier to finish without null safety than this comment depicts, I was still new to flutter then... with null safety, this is just absolutely impossibleeee😂😂 I'm tired, I've been patching up the other parts, but this particular video is impossible, it's been hours, change one thing and the ripple effect will tear you down, I am beginning to feel clean architecture is more trouble than it's worth, I mean not the clean architecture itself, but the testing testing and writing code based on tests, it's silly, it forces you to necessarily make things nullable, like all my Future? literally everything has to be nullable for tests to work😥😥😪😪 and it's useless, because these will never be null, now, when I'm implementing them, I have to start checking for null with ! ! ! !.......ughhhhhhhhhhh, and now I can't check for network connectivity because, can't do a conditional with a null value
hum iam doing the tutorial now also with null safety and i didnt struggle as much as you are depicting in your comment...for the Future just keep everything as is it shouldnt fail your tests...check also similar repositories online which implement this proposal with null safety
@@zehijean8817 lol, what are you saying?? You know when you're running the early tests, you actually have not implemented anything yet, so, the results are gonna be implicitly null in the tests, hence null errors, type null can't be assigned to.... Check in the comments, you'll see people complaining of said error, the only way out is to make the return types nullable
@@zehijean8817 yep, I just done what you asked, now even after fully implementing the repo, and for the get trivia from the number from the repo test, failing miserably type Null is not a subtype of type Future
Finally!!! Been waiting impatiently for this part. Now i know what it feels like when my subscribers wait for my previous series. You're really doing a good job man. I want to see how this ends because im currently loving it and if it goes well, i would be using this architecture for future contents. Thanks once again for your quality content.
Thank you very much =) I really appreciate your work this course worth billions. I promise once I used TDD for my client's project I will support you on Patreon or PayPal keep up the great work .btw I make youtube videos too I will use your TDD to build a full big app in combination with my knowledge really thanks for your work.
My recommendation would be to NEVER EVER check anything that is associated to device connectivity before doing a request, it can potentially be flaky, just let your HTTP client throw connection error.
since the `should cache the data...` test shares everything but one line with `should return remote data` test, would it not be as clean to combine the two and just assert both the data is cached and returned all in one test?
I wish I had more time to pick this up so I know how to communicate with my devs and explain how I need to be able to access payment history and user referrals with my flutter app so I can create reports to keep my affiliates and stockholders up to date… if any one has any tips please share. I appreciate you so much in advance.
Sir, same like NumberTrivia entity, what to do if we have to deal with stream data. How to implement it inside domain repository. Is implemenying Either , or, dartz with stream data??
Thanks again for such a great value. I'm struggling to understand how Right() method knows" which types it must refers to. This all Either/Right/Left is still a little obscure for me. Could you lead me to a tutorial about that part ?
How to tell repository to use other datasource from the presentation layer? In this example you are relying on the internet connectivity to use other datasoruce.
Failed assertion: boolean expression must not be null package:clean_architecture_tdd_course/features/number_trivia/data/repositories/number_trivia_repository_impl.dart 28:25 NumberTriviaRepositoryImpl.getConcreteNumberTrivia
man I copied from the website, and I get errors such as ERROR: Failed assertion: boolean expression must not be null, ERROR: Bad state: Can't call test() once tests have begun running. could you post the entire document from this particular lesson? so that I can check maybe I made a mistake somewhere along the lines?
Wow! such a great tutorial! but is TDD really worth it for small to medium flutter projects? I know using TDD in this tutorial is for educational purposes (and its a great fit for clean architecture indeed), but generally asking.
also, what are your thoughts about 'flutter_clean_architecture' on pub? its architecture is a little bit different than what you explained here. thanks, bro.
According with the documentation ServerException when the response doesn't have a 200 OK , then failures are ServerExceptions became failures because the Repository will catch the Exceptions and return them using the Either type as Failures. For this reason, Failure types usually exactly map to Exception types.
your structure is awesome, bro. But i have a question to ask: "How if i have many features? And how to navigate the Screen between them across features?
I asked my self the same thing. I lean towards mixing it with the Atomic Design Pattern (a frontend Pattern see: bradfrost DOT com/blog/post/atomic-web-design/) where i would map the "features as organisms or even as templates" therefore i have a top level directory called pages where i pull my features together in routable "views". Sadly Uncle Bob Martin in his talks as the Creator of the Clean architecture design seldom goes into that level of detail in all the application layers (thats why it's more popular in the backend) . But it works very well wit an MVC pattern mixed in which is somewhat visible in the most outer layer of the Diagramm in the first episode :) But i'd like to hear from @ResoCoder on what he had in mind :)
@@Belliger1991 yes, i think we should keep watching him. Hope he'll give us a most resonable answer. But in my personal opinion, anyway finally we have to place all of modules in somewhere called "App Module". And the App Module should be the place we'll inject every dependencies. In the Core Folder, we may create a class called Page Router or something like that, and this Page Router will take all of navigate missions, then every screens in each Module can ask Page Router for navigating. This is my opinion, how about you?
@@Belliger1991 the layered architecture presented in these videos is for a whole application (back end/front end/ api etc) while the atomic design is just a design pattern for the presentation layer (UI), same goes for MVC. Once you adopt a clean architecture you can use whatever design pattern you want in each of your layers (MVC, flux, atomic etc). I hope this helps.
I am struggling with the test case. While setting up for exception I get this error on the test case No interaction expected, but following found: MockLocalDataSource.cacheNumberTrivia(null)
if you have Future error then, at the top of your testfile, delete the MockNetworkInfo, add this import import 'package:mockito/annotations.dart'; then do this @GenerateNiceMocks([MockSpec()]) import 'number_trivia_repo_impl_test.mocks.dart'; after these, you will have reds, don't worry then in terminal, run flutter pub add -d build_runner, and after that flutter pub get then, in your terminal again, run this command flutter pub run build_runner build this will clear the errors you have after the command completes execution, and then your tests should work now
the content of the tutorial seems to have been set before null safety implementation so that among other things // class "MockNetworkInfo extends Mock implements NetworkInfo {}" becomes "@GenerateNiceMocks([MockSpec()])" which addresses error messages such as "type 'Null' is not a subtype of". That said I'm still stuck with "expect(result, equals(Left(ServerFailure())));" in test\app\data epositories_impl umber_trivia_repository_impl_test.dart with rippling effects in lib/core/error/failures.dart.
Thank you so much! It's so good to finally see the TDD approach in full practice and not only 10 minute talks...
I think this is by far the best TDD tutorial there is! Thanks a lot and keep it up Matej :)
finally ! your Efforts are very much appreciated bro
@Callan Landyn How does this relate to the tutorial?
Where do you learn all this TDD style?Do you have any cool resources to practice this TDD style with mocks? Any book similar to your style?, BTW cool videos. Hard to find this kind of content.
the test 'should check if the device is online',
wasn't working for me since
repository.getConcreteNumberTrivia(tNumber);
wasn't mocked with a proper when call
adding
when(mockRemoteDataSource.getConcreteNumberTrivia(tNumber)).thenAnswer((_) async => tNumberTrivaModel);
in the arrange section fixed this
Yes I got the same issue, but why it worked in video ?
Got any idea?
thanks for this
@@gameofcodes9832 Because there was no Null Safety checks in Dart at the time the tutorial was recorded. It means now getConcreteNumberTrivia cannot return Null. Instead you have to provide a mocked value.
Boi that stuff is lit.
It's hard to find good intermediate to advanced coding tutorials, this one is fire bro!
I run into an issue with the test
'should return server failure when the call to remote data source is unsuccessful'
verifyZeroInteratctions(mockLocalDataSource);
returned an error and i had to add
reset(mockLocalDataSource) in the arrange part to fix all previous interactions with this mock since it seems not to reset within a test() block.
If this is the case every test should start with a cleanup to reset all mocks before doing testing to not rely on the order of the tests.
verifyNoMoreInteractions also works
Hello Matej. 1 year after you publish this amazing series I'm starting to learn Flutter, but I want to do it the right way, by having a very well organized code as I can see clean architecture and TDD can do.
I had made a question, but it was my bad, I was coding along with you while watching the video, but I realized I had a mistake.It's already solved so I edited this comment to delete such question.
Thanks a lot, and keep it up with your awesome videos buddy!
God bless you!
It seems very overwhelming. The whole 'clean' architecture thing. Could you provide a more in-depth series on clean architecture alone without TDD? Or if you could provide me with any easy-to-comprehend resources to follow? Awesome work btw as always thanks.
It's true that doing TDD can be a bit confusing when you're also learning about the overall architecture. I'm yet to find an easy to follow clean architecture resource (except for this course 😉).
Just try looking at the diagram from the first part and also notice the dependencies of different classes. This is what really matters with Clean Architecture.
"Clean Architecture: A Craftsman's Guide to Software Structure and Design" (Robert C. Martin)
Hi, thank
By the way, I am wondering how at 14:42 , expect(result, equals(Right(tNumberTrivia))); can pass the equality test since they are not the same type. At least for me, it says:
Expected: Right:
Actual: Right:
And the test fail even if NumberTriviaModel extends NumberTrivia
Have you added line 38 at 7:33.
Also, check if you are using Equatable package.
Make sure the method 'getConcreteNumberTrivia' in repository implementation is 'async'
Absolutely brilliant, I've been dreaming of an architecture like this since I started object oriented programming. Thank you for this content, I am very grateful.
Could you possibly do a short video on clean architecture with Firebase?
same thing as this, just use firebase instead of api
Yes
nice video. But I have some questions. 1) what counts as a feature?(when should I make a new feature) and 2) should I put in the core folder a domain & data ? Thanks
Excellent video!!! Your usage of TDD and Clean Architecture are outstanding
Always great tutorials....I follow your series....please make tutorial on firebase integration with flutter
After I finish this series I will start a Flutter App with Firebase. I guess your doubts are pretty close to mine. To listen Firebase data changes passing from the datasource until UI layer. I think that is when Bloc or Provider comes to play. Not sure how yet.
I'm preparing a Firebase series!
@@ResoCoder WoW!! Really? That would be great. I just started an Flutter App. I stopped due to design architecture issues. That's why I am doing this Flutter TDD course first. The only one I found that really focus on Clean and Tests. I already seem to much spaghetti UI Apps. And I really do not want mine to be like those.
Awesome! Really great refactor at the end.
Edit: this was a lot easier to finish without null safety than this comment depicts, I was still new to flutter then...
with null safety, this is just absolutely impossibleeee😂😂 I'm tired, I've been patching up the other parts, but this particular video is impossible, it's been hours, change one thing and the ripple effect will tear you down, I am beginning to feel clean architecture is more trouble than it's worth, I mean not the clean architecture itself, but the testing testing and writing code based on tests, it's silly, it forces you to necessarily make things nullable, like all my Future? literally everything has to be nullable for tests to work😥😥😪😪 and it's useless, because these will never be null, now, when I'm implementing them, I have to start checking for null with ! ! ! !.......ughhhhhhhhhhh, and now I can't check for network connectivity because, can't do a conditional with a null value
hum iam doing the tutorial now also with null safety and i didnt struggle as much as you are depicting in your comment...for the Future just keep everything as is it shouldnt fail your tests...check also similar repositories online which implement this proposal with null safety
@@zehijean8817 lol, what are you saying??
You know when you're running the early tests, you actually have not implemented anything yet, so, the results are gonna be implicitly null in the tests, hence null errors, type null can't be assigned to....
Check in the comments, you'll see people complaining of said error, the only way out is to make the return types nullable
@@zehijean8817 yep, I just done what you asked, now even after fully implementing the repo, and for the get trivia from the number from the repo test, failing miserably
type Null is not a subtype of type Future
@@zehijean8817 ouuh, thanksssssss
moral bozma lan
Thank you so much, you are an amazing human being .
Finally!!! Been waiting impatiently for this part.
Now i know what it feels like when my subscribers wait for my previous series.
You're really doing a good job man.
I want to see how this ends because im currently loving it and if it goes well, i would be using this architecture for future contents.
Thanks once again for your quality content.
I am trying to enter to read the articles but it seems that the page does not work
Thank you very much =) I really appreciate your work this course worth billions. I promise once I used TDD for my client's project I will support you on Patreon or PayPal keep up the great work .btw I make youtube videos too I will use your TDD to build a full big app in combination with my knowledge really thanks for your work.
These videos are GREAT!!!!! THANKSSSSSS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Duration is getting longer, content is getting better
I'm glad you learned something new!
Great tutorial. Hugs from the biggest brazilian community #Flutterando o/
5:35 just want to say that if you use "verify" insted of "expect", you'll get pass whether you input True Or False in the arrange. or CMIIW
Awesome, looking fordward to watch next videos
why didn't you put the first test inside the 'device is online' subgroup?
amazing series! any course with more focus on writing tests, widget tests, unit tests, reusing common test logic etc.?
i have problems, the arguement type 'future' can`t be assigned to the parameter type 'dynamic Function()'
abstract class NetworkInfo {
Future? get isConnected;
}
adding an ? operator solved my Future error
Thanks! It was evaluatin doing that, and seeing your comment motivated me to try, and it worked also for me!
awesome tutorial, I feel Im on track
My recommendation would be to NEVER EVER check anything that is associated to device connectivity before doing a request, it can potentially be flaky, just let your HTTP client throw connection error.
After 14:42 I get Failure instead of dynamic... Anyone have ideas on whats happening?
Make sure the method 'getConcreteNumberTrivia' in repository implementation is 'async'
you are the best keep it up
since the `should cache the data...` test shares everything but one line with `should return remote data` test, would it not be as clean to combine the two and just assert both the data is cached and returned all in one test?
Hi, if I don't want to use high order functions, I can use for example an optional variable or in TDD isn't a good practice?
I wish I had more time to pick this up so I know how to communicate with my devs and explain how I need to be able to access payment history and user referrals with my flutter app so I can create reports to keep my affiliates and stockholders up to date… if any one has any tips please share. I appreciate you so much in advance.
Getting this error... Error-The superclass, 'Bloc', has no unnamed constructor that takes no arguments.
Sir, same like NumberTrivia entity, what to do if we have to deal with stream data. How to implement it inside domain repository. Is implemenying Either , or, dartz with stream data??
very hard to understand it, it takes my whole day .. let's see what's next 👍 overall best series on TDD CA ✔✌
Thanks again for such a great value. I'm struggling to understand how Right() method knows" which types it must refers to. This all Either/Right/Left is still a little obscure for me. Could you lead me to a tutorial about that part ?
what is name of the plugin that you used for generating arrange, act, assert scaffold?
excellent!!
How to tell repository to use other datasource from the presentation layer? In this example you are relying on the internet connectivity to use other datasoruce.
In summary, in the repository implement is the business logic developed? And in the use cases is it called only? greetings from Chile
Failed assertion: boolean expression must not be null
package:clean_architecture_tdd_course/features/number_trivia/data/repositories/number_trivia_repository_impl.dart 28:25 NumberTriviaRepositoryImpl.getConcreteNumberTrivia
Great video!!
Hey man, are you fine? You uploaded your last video one year ago. Hope everything is okay.
If you read this: Thanks for your videos! They are awesome!
Thank you!!
Amazing video again bro, thanks a lot. Could you upload the final code to check it please? I would greatly appreciate that.
Thanks bro
man I copied from the website, and I get errors such as ERROR: Failed assertion: boolean expression must not be null, ERROR: Bad state: Can't call test() once tests have begun running.
could you post the entire document from this particular lesson? so that I can check maybe I made a mistake somewhere along the lines?
Don't copy, code along. You'll learn much more and the code works as well the tests.
Wow! such a great tutorial!
but is TDD really worth it for small to medium flutter projects? I know using TDD in this tutorial is for educational purposes (and its a great fit for clean architecture indeed), but generally asking.
also, what are your thoughts about 'flutter_clean_architecture' on pub? its architecture is a little bit different than what you explained here. thanks, bro.
Cool
what is aaaTest extendsion?
cool
What's the diference between ServerException and ServerFailure?
According with the documentation ServerException when the response doesn't have a 200 OK , then failures are ServerExceptions became failures because the Repository will catch the Exceptions and return them using the Either type as Failures. For this reason, Failure types usually exactly map to Exception types.
your structure is awesome, bro.
But i have a question to ask: "How if i have many features? And how to navigate the Screen between them across features?
I asked my self the same thing. I lean towards mixing it with the Atomic Design Pattern (a frontend Pattern see: bradfrost DOT com/blog/post/atomic-web-design/) where i would map the "features as organisms or even as templates" therefore i have a top level directory called pages where i pull my features together in routable "views".
Sadly Uncle Bob Martin in his talks as the Creator of the Clean architecture design seldom goes into that level of detail in all the application layers (thats why it's more popular in the backend) . But it works very well wit an MVC pattern mixed in which is somewhat visible in the most outer layer of the Diagramm in the first episode :)
But i'd like to hear from @ResoCoder on what he had in mind :)
@@Belliger1991 yes, i think we should keep watching him. Hope he'll give us a most resonable answer.
But in my personal opinion, anyway finally we have to place all of modules in somewhere called "App Module". And the App Module should be the place we'll inject every dependencies.
In the Core Folder, we may create a class called Page Router or something like that, and this Page Router will take all of navigate missions, then every screens in each Module can ask Page Router for navigating.
This is my opinion, how about you?
@@Belliger1991 the layered architecture presented in these videos is for a whole application (back end/front end/ api etc) while the atomic design is just a design pattern for the presentation layer (UI), same goes for MVC. Once you adopt a clean architecture you can use whatever design pattern you want in each of your layers (MVC, flux, atomic etc). I hope this helps.
@ResoCoder please tell us your thoughts on this point
Only thing I don't like is to use higher order function
I'm fucking in love with you, man!
quite long wait this time..
31:26 where stop
I would like to thank your biological parents for bringing you into this world.
Anyone getting error on:
final result = tNumberTriviaModel.toJson();
final expectedMap = {
"text": 'Test text',
"number": 1,
};
expect(result, expectedMap);
----Terminal: ----
Expected: {'text': 'Test text', 'number': 1}
Actual: {'text': 'Test text', 'mumber': 1}
Which: is missing map key 'number'
Actual: {'text': 'Test text', 'mumber': 1} I thing there is typo in the loaded data.
I am struggling with the test case. While setting up for exception I get this error on the test case
No interaction expected, but following found: MockLocalDataSource.cacheNumberTrivia(null)
This guy should be on the flutter boring show
Am I that boring? 😂
if you have Future error then, at the top of your testfile, delete the MockNetworkInfo,
add this import
import 'package:mockito/annotations.dart';
then do this
@GenerateNiceMocks([MockSpec()])
import 'number_trivia_repo_impl_test.mocks.dart';
after these, you will have reds, don't worry
then in terminal, run flutter pub add -d build_runner, and after that flutter pub get
then, in your terminal again, run this command
flutter pub run build_runner build
this will clear the errors you have after the command completes execution, and then your tests should work now
Can you share your file to see the changes applied. I follow step by step your recommendations but the error in the annotation line still goes on
@@hamidpinilla4431 I don't have access to my computer right now, make a GitHub gist with your code and send me the link let me see
@@maran.ath4 I fixed it. The error was because the version of mockito that i used it doesn't included the decorator @GenerateNiceMocks yet
@@hamidpinilla4431 so everything is working fine now?
@@maran.ath4 yes, thanks
type 'Null' is not a subtype of type 'Future'
MockNetworkInfo.isConnected
What should i do ?
the content of the tutorial seems to have been set before null safety implementation so that among other things // class "MockNetworkInfo extends Mock implements NetworkInfo {}" becomes "@GenerateNiceMocks([MockSpec()])" which addresses error messages such as "type 'Null' is not a subtype of".
That said I'm still stuck with "expect(result, equals(Left(ServerFailure())));" in test\app\data
epositories_impl
umber_trivia_repository_impl_test.dart with rippling effects in lib/core/error/failures.dart.