I need to know the flow to write full tests in my project
I read lot of docs but I have some questions to make sure I actually understood unit-test well.
1-Do i should learn any of instrumentation test framework such Espresso and any of local tests JUnit with Mockito ?
2-In Espresso, for each activity, Must I write a test class?
3-The activities in UI test are independent, as I run test class of each activity or can I run multiple tests classes for different activities?
4-How can I test the viewModel and Repository and check the response state?
1- It depends on your requirement However JUnit and Mokito are for Unit testing (function code test only) where as Expresso Espresso allows you to perform functional/instrumentation testing, in other words allows you to simulate user input and verify UI state and navigation.
2-No you can write your entire code in a single test class as well, but for separation of concerns you should keep it in different classes
3-It depends how you have implemented the test cases.
4- You can use JUnit or Mokito for testing the ViewModels or Repositroy. You just need to call the method which which calls some API and return some Value you get the same in your test case code block.
Hope this will help thanks.
Answered By – Abhishek Kumar