Everytime I get stuck in my Android testing knowledge and I can't find what I'm looking for in the docs, I find a video by you and it helps answer most if not all of my questions, thank you, keep doing what you do :)
I was looking for a way to test navigations for a long time and this video explains how to do it in a simplistic manner. Philipp YOU ARE THE BEST 😎. By the way to create a new test class from a class (or switch to an existing test class) just use CTRL + SHIFT + T shortcut key. Thanks a lot.
Love it. After this bit, I will be extremely comfortable with every aspect of modern professional Android development... I mean shit I have been doing it since Eclipse in 2009, MVC. SQLiteOpenhelper, crashes, crashes, ANRs.... lol. Things have come a long way, I can't wait to see how Compose goes!!! (I put off testing for too long really was the issue why as a Sr developer I am just doing this, I love testing now though )
Hi everyone, I've got SecurityException: Writing DEX files are not allowed, when trying to call Mockito's mock() function for navController. Look's like it only happens on Android 14. Any suggestions?
I have an unrelated question. at 3:30 Phillip used the floating button (fabAddShoppingItem.setOnCli...) without using binding or even findById. Does anyone know how he could do this?
thank you very much ... for tutorials learnt a lot from you .. i have question after finishing this series..which project from your website i should learn ..to atleast get the job ..
Thanks for your video Phillip! I learnt a lot from it. How do you test navigation if you have nav args? Would anyvalue work in the navdirections action?
@@saumilpatel2480 In launchFragment... get reference to viewModel.currentImageUrl, after pressBack() get url using getOrAwaitValue() and then compare with "".
@@saumilpatel2480 : Hello , Hope this will help you my friend ideone.com/WvAofp , please try it and give me ur feedback, as I'm still not good at testing.
@@saumilpatel2480 Edit : I think it was wrong to assign/use the real viewModel instance, and we should use a fakeViewModel like this : ideone.com/UInCNT , I think if u saw the next videos , u will realize this by yourself, hope my answer helped u man!
Everytime I am getting this error while testing navigation for ShoppingFragment. java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState Can anyone please help ???
java.lang.AbstractMethodError: abstract method "java.util.List org.mockito.invocation.Invocation.getArgumentsAsMatchers()" i got this error would you please help me to solve this?
You have to remove the following androidTestImplementation "com.linkedin.dexmaker:dexmaker-mockito:2.12.1" androidTestImplementation "org.mockito:mockito-core:3.9.0" and add androidTestImplementation "org.mockito:mockito-android:3.9.0"
Everytime I get stuck in my Android testing knowledge and I can't find what I'm looking for in the docs, I find a video by you and it helps answer most if not all of my questions, thank you, keep doing what you do :)
I was looking for a way to test navigations for a long time and this video explains how to do it in a simplistic manner. Philipp YOU ARE THE BEST 😎. By the way to create a new test class from a class (or switch to an existing test class) just use CTRL + SHIFT + T shortcut key. Thanks a lot.
Love it.
After this bit, I will be extremely comfortable with every aspect of modern professional Android development...
I mean shit I have been doing it since Eclipse in 2009, MVC. SQLiteOpenhelper, crashes, crashes, ANRs.... lol.
Things have come a long way, I can't wait to see how Compose goes!!!
(I put off testing for too long really was the issue why as a Sr developer I am just doing this, I love testing now though )
Hi everyone, I've got SecurityException: Writing DEX files are not allowed, when trying to call Mockito's mock() function for navController. Look's like it only happens on Android 14. Any suggestions?
Thank you so much, Philipp! Great job! Keep going!
Thanks you're welcome! :)
@Phillipp Thanks for this awesome video.
But how are you able to test on backPressed from Fragment2 in isolation with Fragment1?
I have an unrelated question. at 3:30 Phillip used the floating button (fabAddShoppingItem.setOnCli...) without using binding or even findById. Does anyone know how he could do this?
The way he did is deprecated now. Stick to view binding and you'll be fine.
thank you very much ... for tutorials learnt a lot from you .. i have question after finishing this series..which project from your website i should learn ..to atleast get the job ..
since the android studio has the espresso recorder, why not use that recorder to do all those tests automatically?
how would you use this with databinding?
thank you sir.. great explanation
awesome tutorials. thank you again
I did the first test but the test for empty curImageUrl is difficult. Someone please help me
@Test
fun pressBackButton_imageUrlSetToEmptyString(){
val testViewModel = ShoppingViewModel(FakeShoppingRepository())
val navController = mock(NavController::class.java)
launchFragmentInHiltContainer {
Navigation.setViewNavController(requireView(), navController)
viewModel = testViewModel
}
pressBack()
val value = testViewModel.curImageUrl.getOrAwaitValue()
assertThat(value).isEmpty()
}
your tutorial is very helpful . Nice
Glad it was helpful!
Awesome Video
Great tutor!! Thank you!!
Thanks for your video Phillip! I learnt a lot from it. How do you test navigation if you have nav args? Would anyvalue work in the navdirections action?
The same way, just check that the navigate function was called with the right parameters
@@PhilippLackner Thank you. Will Try that out this night
I tried but failed. Is that caused by using viewbinding? You're using syntetic which is going to be deprecated
just override oncreate view and return binding.root from there
big thanks
Thank you Bro
thank you
Thanks man
How to test null URL? Have you tried?
@@saumilpatel2480 In launchFragment... get reference to viewModel.currentImageUrl, after pressBack() get url using getOrAwaitValue() and then compare with "".
@@pavesid Can you please put down the code, seems easy but i'm lost. Thank you
@@saumilpatel2480 : Hello , Hope this will help you my friend ideone.com/WvAofp , please try it and give me ur feedback, as I'm still not good at testing.
@@saumilpatel2480 Edit : I think it was wrong to assign/use the real viewModel instance, and we should use a fakeViewModel like this : ideone.com/UInCNT , I think if u saw the next videos , u will realize this by yourself, hope my answer helped u man!
Who is that man who is constantly putting a dislike on every video? :) It's gonna be your hater
Second
Everytime I am getting this error while testing navigation for ShoppingFragment.
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
Can anyone please help ???
Any one if facing the same issue with your device , please keep the device unlocked.
java.lang.AbstractMethodError: abstract method "java.util.List org.mockito.invocation.Invocation.getArgumentsAsMatchers()"
i got this error would you please help me to solve this?
You have to remove the following
androidTestImplementation "com.linkedin.dexmaker:dexmaker-mockito:2.12.1"
androidTestImplementation "org.mockito:mockito-core:3.9.0"
and add
androidTestImplementation "org.mockito:mockito-android:3.9.0"
@@ahmedfahimfoysaleishon2097 Thanks very much bro, this totally works!
@@ahmedfahimfoysaleishon2097 probably you dont remenber haha, but this comment saved a lot of my time, thnx bro!
@@brunonunes6532 True, I don't remember I left a comment here ;D
I did the first test but the test for empty curImageUrl is difficult. Someone please help me