The Ultimate Guide to Android Testing (Unit Tests, UI Tests, End-to-End Tests) - Clean Architecture

  Рет қаралды 107,793

Philipp Lackner

Philipp Lackner

Күн бұрын

In this video you will learn how you can test your clean architecture app. I'll cover unit tests, integration UI tests and end-to-end tests so you're ready to do that in your own app.
⭐ Get certificates for your future job
⭐ Save countless hours of time
⭐ 100% money back guarantee for 30 days
⭐ Become a professional Android developer now:
pl-coding.com/premium-courses...
💻 Let me personally review your code and provide individual feedback, so it won't backfire and cost you a fortune in future:
elopage.com/s/philipplackner/...
Subscribe to my newsletter for regular Android, Kotlin & Architecture advice!
pl-coding.com/newsletter
Join this channel to get access to perks:
/ @philipplackner
Get the initial source code for this video here:
github.com/philipplackner/Cle...
Get the final source code for this video here:
github.com/philipplackner/Cle...
Regular live codings on Twitch:
/ philipplackner
Join my Discord server:
/ discord
Regular programming advice on my Instagram page: / _philipplackner_
Checkout my GitHub: github.com/philipplackner
You like my free content? Here you can buy me a coffee:
www.buymeacoffee.com/philippl...
00:00 - Why writing tests is important
02:39 - The different types of tests
05:41 - Explaining the test dependencies
10:53 - Writing our first unit test
29:22 - Integration UI test

Пікірлер: 127
@ricardomuiambojunior4816
@ricardomuiambojunior4816 2 жыл бұрын
Thank god for your existence man.
@joemoe5954
@joemoe5954 2 жыл бұрын
This is exactly the content KZfaq is lacking ! Thank you for making this !
@bhupenjoshi7599
@bhupenjoshi7599 2 жыл бұрын
You are doing a great job philipp... I am watching your videos again and again. Just in love with your way of explaining things...😘😘
@sley664
@sley664 Жыл бұрын
Your tutorial are clean as your architecture ! Insane content, it save me a lot of times !
@mikec4220
@mikec4220 2 жыл бұрын
28:44 that was the perfect description of the feeling! :D:D Thanks for your work Phillip!
@genctasbasi
@genctasbasi Жыл бұрын
That's a priceless content there, clear & to the point. Well done.
@mintunandi1002
@mintunandi1002 2 жыл бұрын
Thank you. Love to see more video on Compose UI testing
@bmwr69s19
@bmwr69s19 2 жыл бұрын
Phillipp, you decided to destroy me. I don't do almost anything but watch your videos. I absolutely fell in love💘💘 . You are the best teacher in the world! Thank you very much!
@PhilippLackner
@PhilippLackner 2 жыл бұрын
❤️❤️❤️
@luckydevil1601
@luckydevil1601 Жыл бұрын
Incredible testing content, thank you so much! I can't even. This is awesome!
@pankajsagar9550
@pankajsagar9550 2 жыл бұрын
if you want really gain knowledge about android it is right channel , I have learnt lot of from it thank you philipp
@sepideh1085
@sepideh1085 2 жыл бұрын
I've just finished it . The more time passes , the more people realize the value of this video
@Mreto17
@Mreto17 2 жыл бұрын
Man, thank you for uploading this video. This is really helpful to me
@paulnjoroge6008
@paulnjoroge6008 2 жыл бұрын
Keep doing this. For sure you are helping many people out here.
@PhilippLackner
@PhilippLackner 2 жыл бұрын
That's the plan!
@andrevitorpietro357
@andrevitorpietro357 2 жыл бұрын
Thanks again Philip! Amazing video again !
@elijahonduso
@elijahonduso 2 жыл бұрын
Am late but not out. This is amazing. This was long overdue.
@Sc2MooDy
@Sc2MooDy 2 жыл бұрын
Amazing job, as always. Thanks
@mrdrugdesigner
@mrdrugdesigner Жыл бұрын
Thanks Phillip for this amazing content.
@tanjimahmed213
@tanjimahmed213 2 жыл бұрын
Thanks, Philipp for this Awesome video
@buszi_
@buszi_ 2 жыл бұрын
It's so great that you cover such important topic, in our company a skill in Unit testing is even mandatory for Junior/Intern position, because it's so crucial to write tests (nobody will write them for you if you create a pull request), and so many candidates are rejected because of the lack of this skill Also it is amazing that you do so with one of your current poroject, many courses cover it as "I HaVe A hAmBuRgEr ClAsS, lEtS WrItE UnItTest", and the skill of testing on a living project is really crucial Huge +1 form me
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Thanks a lot for the amazing feedback!
@buszi_
@buszi_ 2 жыл бұрын
I think you should do a followup video about Mocking (Mockito or Mockk) and verifying mocks, because I think that actually nobody uses "fake components"
@techmarinar
@techmarinar 2 жыл бұрын
hey man , thank you very much , you really conquered our hearts, god bless you
@weaponx3373
@weaponx3373 9 ай бұрын
thanks, learned a lot !!
@roshanrai9089
@roshanrai9089 2 жыл бұрын
Was looking something like that you seem to know your audience very well !!
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Hope you like it!
@pinoy_marites_beh
@pinoy_marites_beh 2 жыл бұрын
Hope you make a TDD video covering outside-in and classicist approach using uncommon convention where test classes are suffixed with the word "should".
@AndrewDChristie
@AndrewDChristie 2 жыл бұрын
this was a very helpful video, learnt a lot about test structure,very useful for a developer new to testing
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Glad it was helpful!
@GN9K71
@GN9K71 Жыл бұрын
Very important and usefull video!
@winsonmac
@winsonmac 2 жыл бұрын
Thank you very much!
@frankyjunior6005
@frankyjunior6005 2 жыл бұрын
finally thank you for your good explanation. easy to understand
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Glad to hear that!
@mehdiparsaei1867
@mehdiparsaei1867 2 жыл бұрын
Amazing! Tanks a lot! Change : Unit Tests, UI Tests, End-to-End Tests => Unit Tests, Instrumented Tests, End-to-End Tests If you would prefer as well.
@PhilippLackner
@PhilippLackner 2 жыл бұрын
But every instrumented test I show here is a UI test
@johndominicjasmin
@johndominicjasmin 2 жыл бұрын
Wow thank you so much♥️♥️
@Nick-cx4rs
@Nick-cx4rs Жыл бұрын
Awesome tutorial thank you rly.
@pereyrarg11
@pereyrarg11 Жыл бұрын
thanks for sharing!
@venkatesh4307
@venkatesh4307 2 жыл бұрын
Thank you very much 🥰
@enzoteles2037
@enzoteles2037 2 жыл бұрын
I love you phillipp, you are the best of the world, tks
@rafaelalberto8689
@rafaelalberto8689 2 жыл бұрын
Great job!!
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Thank you!
@devOmarAZ
@devOmarAZ 2 жыл бұрын
Thanks Philip very mush
@bjornk.567
@bjornk.567 2 жыл бұрын
Was nice to see how you do testing, thanks for sharing! Let me comment on what I noticed while watching: 1) When testing the GetNodes UseCase, you're faking the repository instead of the dao. This has the setback that the behavior of the fake might not mimic the actual repositories implementation, especially over time when your code and structure changes. When you refactor you repository code, you might change e.g. the semantics of getNodesById -- say for exception handling. When you have tests for your repository separately, you'll adjust them since they broke. But you'll certainly forget to adjust this UseCase test. This will result in this UseCase test becoming useless. Things will improve when you fake the dao, since changes to the semantics of the dao will happen less often -- and of course you'll find issues due to changed repository semantics. If you have concepts on your mind how to avoid that your UseCase test becomes useless following your presented test pattern because it's not updated on changes of dependencies, I'd be glad to hear about that. 2) Keep your tests as tidy as you keep your production code, the same principles apply -- especially DRY, so don't just copy&paste, it will give you headaches later. 3) Why are you using the @Throws annotation in your AddNote UseCase? Are you planning for Java interop?
@HappyLeoul
@HappyLeoul 2 жыл бұрын
I am also not liking how the composable are copied into the test class.We're basically maintaining the same code for the main code and the test code. How can you make It tidy and not copy the code?
@arthurdamous
@arthurdamous 2 жыл бұрын
Thank you very much
@suren6413
@suren6413 2 жыл бұрын
You are the best. I have learned a lot by your tutorials. Can you please upload a video for all Functional Tests, Unit Test, instrumentation test and UI test in Java. ? Even if it's a paid version, it is ok.
@sohirhashem7218
@sohirhashem7218 2 ай бұрын
you are the best 🥰🥰thank you so much
@morbix3683
@morbix3683 2 жыл бұрын
Holy ****! Thank you!!!! Philipp breaking the android community!!!
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Thanks man!!
@orangasli2943
@orangasli2943 Жыл бұрын
1. So I already understand how to put the UI in the layout .. 2. Making the UI to be clickable 3. Making the UI to scroll And yes you're right that I need my build time to be faster.. And I am interested how to integrate unit test with a mocking object of the android components.. Hopefully I can finish this
@ProvakorKonik
@ProvakorKonik 2 жыл бұрын
Awesome love you
@moeabushawish9567
@moeabushawish9567 2 жыл бұрын
Hey Philipp, sorry if you mentioned this before but are you gonna make either Flutter, React Native, or KMP tutorials? I love you're well-paced and properly architectured teaching style. I've had enough of other tutorials that teach you how to make a todo list app in 5 minutes all in one class. I want a professional, longer, well-pace, and architectured multiplatform tutorial.
@alwaysbrillant10
@alwaysbrillant10 Жыл бұрын
Please can you make this same video but for projects making network calls? Projects that use coroutines and flow as well like this one
@yusufsafrudin7533
@yusufsafrudin7533 Жыл бұрын
great video, can you make testing for viewmodel using stateflow
@cybersnake
@cybersnake 2 жыл бұрын
Aw yeeessss an update! 😎
@muhammadsarimmehdi
@muhammadsarimmehdi 2 жыл бұрын
How do you test the delete notes usecase? It seems I would need to add an extra method inside the DeleteNotes usecase to return the repository and check whether the note is there or not
@malikkahfi2534
@malikkahfi2534 2 жыл бұрын
Thanks 😘
@anandharajramasamy816
@anandharajramasamy816 Жыл бұрын
Great work! ,Could you please include webview UI test case in jetpack compose
@nilayparikh6693
@nilayparikh6693 2 жыл бұрын
Hey philip I have enjoyed this video and please make one video with adding AI in application
@haykmkrtchyan7093
@haykmkrtchyan7093 2 жыл бұрын
Man you're an Android beast)))
@BCSLalBihariPandey
@BCSLalBihariPandey 2 жыл бұрын
Please please make a detailed video on Bound Services.
@baselnat93
@baselnat93 2 жыл бұрын
thanks for the video
@PhilippLackner
@PhilippLackner 2 жыл бұрын
You're welcome
@nabazbarzanji3221
@nabazbarzanji3221 2 жыл бұрын
Wow Perfect
@abhilashpatel559
@abhilashpatel559 Жыл бұрын
Basically iam a single web application tester in my company. As part of the new project they assigned me as Android tester so just guide me What's the exact thing to do in this . They just telling to test Android devices. As part of KT They just delivered some kind of stuff but unfortunately idint get it . CTS VTS GTS. Iam fully confused that what they actually talking about .... Finally make a video from Scratch who is starting their carrier as Android testing Thank you 😊
@vimalshanmugam9046
@vimalshanmugam9046 2 жыл бұрын
Plzz make video on binding adapter Philipp 🙌🏻
@okeuwechue9238
@okeuwechue9238 Жыл бұрын
In Android Studio are there any limitations in using AndroidX&Junit5 for instrumented tests?
@PankajKumar6493
@PankajKumar6493 7 ай бұрын
I'm getting Dagger duplicate binding error even after using UninstallModule on my AppModule in the test class. Do we need to do something more to fix this? How can it have duplicated binding when AppModule is already uninstalled fromt the test class
@mehranbehbahani3050
@mehranbehbahani3050 2 жыл бұрын
28:43 made me laugh out loud! It is true though.
@mandroidx1474
@mandroidx1474 2 жыл бұрын
I feel like i won lottery ,thanks phillip 💚💚
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Thanks!! Glad it helps
@i_fahimkhan
@i_fahimkhan 2 жыл бұрын
Hi, Phillip, I have a question, I have a production-level project but it does not contain any tests so if I were to implement unit tests in that same project can I add the tests to the production level directly or I should create a separate project for tests that will be separate from production also what is the industry standard? and thank you for reading it.
@astatalol
@astatalol 2 жыл бұрын
Hi man, not Philip but the tests should be on the same project, on the com.test directory for unit tests and com.androidTest for the Instrumentation tests and UI tests, hope this helps.
@philipjanbaruis7040
@philipjanbaruis7040 Жыл бұрын
and afaik, the directory hierarchy (inside the test directory) should be same as the production one.
@kareemkamal6185
@kareemkamal6185 2 жыл бұрын
hey, in Spotify play list in video 13 there are more than 10 person have the same problem in comment of "@Quang Đạt" please if anyone can help tell us if u can't set Like to make philipp see it please..
@Joe-yu9wc
@Joe-yu9wc Жыл бұрын
Hi Man, do you have premuim testing course?
@ediotTV
@ediotTV 2 жыл бұрын
Love you Sir....
@PhilippLackner
@PhilippLackner 2 жыл бұрын
I love you too, Donald
@ediotTV
@ediotTV 2 жыл бұрын
@@PhilippLackner sir can you please tell me the the shortcut to see the suggestions popping in methods
@muhammadsarimmehdi
@muhammadsarimmehdi 2 жыл бұрын
how would you just test the view model here? I tried mocking the SavedStateHandle but I get an error about duplicate bindings (I just bind the SavedStateHandle in the TestAppModule object class)
@PhilippLackner
@PhilippLackner 2 жыл бұрын
You don't need to bind the SavedStateHandle. Hilt will automatically provide it.
@squale1343
@squale1343 7 ай бұрын
The unexpected uss of the word "orgasm" got me 😂
@Ilamarea
@Ilamarea 2 жыл бұрын
The instrumented test fails, it can't find a view with given tag. useUnmergedTree = true does not help. Adding a delay does not help. Using tags the same way on other views works fine. assertExists also fails. Any ideas? e/ Also the EndToEnd test fails because it's missing focus on the first action. [e: No input session started. Missing a focus?] Think update to composable introduced focusModifier?
@imnithish
@imnithish 2 жыл бұрын
🔥
@emmanuelmtali1594
@emmanuelmtali1594 Жыл бұрын
It's the orga*m part for me. Hahahahaha love your tutorials
@baselnat93
@baselnat93 2 жыл бұрын
one question. when to use fake objects and when to use mockk to mock objects?
@PhilippLackner
@PhilippLackner 2 жыл бұрын
mock objects make sense when you have something with tons of functions. Implementing a fake for that would require you to write an implementation for all these functions. With a mock you only implement the ones needed. Most of the times, mocks actually make more sense
@devOmarAZ
@devOmarAZ 2 жыл бұрын
if you refactor this great app to multi module it will be our document to architect our apps ... thx
@themateoo
@themateoo 7 ай бұрын
It's 2023 and I can't run this project with latest versions of... all the stuff that it's using. I spend half a day and still no success. This is crazy.
@sudarshanh.s.521
@sudarshanh.s.521 7 ай бұрын
I am late to this video, Code is very hard to build now. Can you update code base.
@muhammadsarimmehdi
@muhammadsarimmehdi 2 жыл бұрын
Reason: Expected exactly '1' node but could not find any node that satisfies: I am following the same steps as you for my composable but still getting this error. In my composable, however, I call other composables and the node with the tag is located in one of them
@onuremrekaradag7655
@onuremrekaradag7655 11 ай бұрын
It seems that you've assigned the tag to the OrderSection's Modifier and forgot to use that passed modifier inside OrderSection. As a result, the node not be present in the tree and causing the test to fail.
@chenchiaho
@chenchiaho 2 жыл бұрын
How to properly run your source code? I like all your tutorials, but I actually never successfully run any of them...
@rohanr4783
@rohanr4783 2 жыл бұрын
Sir please make a video on how to Use FIREBASE with Jetpack Compose
@PhilippLackner
@PhilippLackner 2 жыл бұрын
The same way you used it before. Only the ui layer changed with compose which firebase has nothing to do with
@hassanjamil841
@hassanjamil841 Жыл бұрын
I got the required knowledge for different types of android application tests, the video is just amazing and you really doing a very great job doing your huge efforts in making this free up to dated content for the android developers, I am really happy following or subscribe your channel, keep it up boy, Salute 🫡
@undeadredemption_
@undeadredemption_ 10 ай бұрын
28:41 🤣🤣🤣🤣
@unknwn05
@unknwn05 2 жыл бұрын
Y O U A R E T H E B E S T
@carlosmartinezsuarez3541
@carlosmartinezsuarez3541 4 ай бұрын
As always... what a crack
@Berk45632
@Berk45632 2 жыл бұрын
I love that in your testing videos, when your tests fail, you think there is something wrong with the test function. 😂😂😂 Pretty ironic.
@PhilippLackner
@PhilippLackner 2 жыл бұрын
😂😂
@dontforgettovote531
@dontforgettovote531 2 жыл бұрын
it would be super cool if you could a video like this one kzfaq.info/get/bejne/f9x2hq2Hua2okmg.html, basically refactoring the app to use modules instead.
@ytmiva2
@ytmiva2 2 жыл бұрын
Please don't teach to add randomisation in unit tests. Other than that, there is a lot of useful info here. Thanks for the video!
@bejancorneliu4238
@bejancorneliu4238 Жыл бұрын
How to test with real rest api? Let say my screen needs to perform api request? How to make unit test wait for api to finish?
@RonnyBubke
@RonnyBubke 2 жыл бұрын
Your explanation is wrong. Unit tests don't test a component class or function but a feature. This is the big misunderstanding which is also mentioned by Uncle Bob. Implementation details like inner classes should never been tested separately but tested as a black box. Tests should trigger your ViewModel and expect an effect on your ViewState, Database or Http-Request. You never should test something in between!
@duckieDidIt
@duckieDidIt 2 жыл бұрын
down voting way too many ads
@mikec4220
@mikec4220 2 жыл бұрын
Well - the guy has to make his money from this somehow - you know how much time it takes to make such good quality content? Cmon - your comment is disrespectful!
@duckieDidIt
@duckieDidIt 2 жыл бұрын
@@mikec4220 there are plenty of people who make money on KZfaq without excessive ads 🤷🏽‍♂️
@mikec4220
@mikec4220 2 жыл бұрын
@@duckieDidIt instead of putting such comments just install an add blocker and that will solve your issue.
@duckieDidIt
@duckieDidIt 2 жыл бұрын
@@mikec4220 it’s called the freedom of speech you should learn a thing or two about it
@mikec4220
@mikec4220 2 жыл бұрын
@@duckieDidIt and you should learn a thing or two about respecting other peoples work ;)
@trollberserker1515
@trollberserker1515 5 ай бұрын
The setup boilerlate is huge for the instrumented tests.
@chuka_obi5167
@chuka_obi5167 2 жыл бұрын
Thanks for your video Philipp! This was very educational and I learnt a lot from it. For some reason, during my Integration section following the tutorial, I kept on getting the error "java.lang.AssertionError: Failed to perform isDisplayed check. Reason: Expected exactly '1' node but found '4' nodes that satisfy: (TestTag = 'ORDER_SECTION')" for the function clickToggleOrderSection_isVisible. Not sure what I am doing wrong
@onuremrekaradag7655
@onuremrekaradag7655 11 ай бұрын
It seems that you've assigned the tag to the OrderSection's Modifier and forgot to use that passed modifier inside OrderSection. As a result, the node not be present in the tree and causing the test to fail.
@samdroid37
@samdroid37 Жыл бұрын
getting this error. please help. -> android.content.ActivityNotFoundException: Unable to find explicit activity class {com.samm.brewerysearch.test/androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared ?
@arturolatorre371
@arturolatorre371 2 жыл бұрын
Anyone gave this a try? I get an error when I run the Integration test, the trace says: Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugAndroidTestRuntimeClasspath'
@BCS_AAMIRASHRAF
@BCS_AAMIRASHRAF Ай бұрын
instead. of composerule.setcontent do composerule.activity.setcontent
@vladk3524
@vladk3524 Жыл бұрын
composeRule.activity.getString(resId = R.string.my_string)
MVVM vs. MVI - Understand the Difference Once and for All
18:40
Philipp Lackner
Рет қаралды 36 М.
5 Fatal Coroutine Mistakes Nobody Tells You About
18:15
Philipp Lackner
Рет қаралды 86 М.
Finger Heart - Fancy Refill (Inside Out Animation)
00:30
FASH
Рет қаралды 29 МЛН
I'm Excited To see If Kelly Can Meet This Challenge!
00:16
Mini Katana
Рет қаралды 30 МЛН
哈莉奎因以为小丑不爱她了#joker #cosplay #Harriet Quinn
00:22
佐助与鸣人
Рет қаралды 8 МЛН
Java Unit Testing with JUnit - Tutorial - How to Create And Use Unit Tests
21:35
Андроид - Автотесты
2:04:45
Yandex for Developers
Рет қаралды 3,2 М.
Unit тестирование в Android c Clean architecture
21:09
Тимофей Коваленко
Рет қаралды 12 М.
KMP vs. Flutter - Who Will Win The Cross-Platform Battle?
16:19
Philipp Lackner
Рет қаралды 40 М.
Finger Heart - Fancy Refill (Inside Out Animation)
00:30
FASH
Рет қаралды 29 МЛН