How to Test Networking Layer in Android!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's say you have a retrofit service in your repository or new model and you want to test that repository using some kind of real implementation of that retrofit service you can do that with something called a mock web server so the first thing you define this mock web server right you create it and then when creating your service like this is in the unit test you can create normally your rrit service and here in the base URL you can specify the URL of the active Mo ser and then here we are testing this view model in this view model we are just simply using this post service to fetch posts and here in the fetch post it is simply an interface that will get us some posts here are the post you are going to get then what you need to do is that you can create something called mock response and here you can set up the body and the code for example 200 or 400 for the response code here is the body here is the gson we do we have here and then you can simply inq that response and then do your normal thing you want to test which is getting the actual post and do your normal search
Info
Channel: Charfaoui Younes
Views: 690
Rating: undefined out of 5
Keywords:
Id: du3B__vGOiw
Channel Id: undefined
Length: 0min 59sec (59 seconds)
Published: Fri Feb 02 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.