-
Notifications
You must be signed in to change notification settings - Fork 0
Segregating the tests in android
Devrath edited this page May 16, 2021
·
1 revision
-
JVM-TEST------> The android application runs onJava-Virtual-Machine. -
DEVICE-TEST---> But an android application uses the resources of an android device to perform some tasks.
- We can write all our
logic computationthat involves things like thebusiness logic. - We can use the
unit testfor these types of tests. - We can literally write
thousandsof these types of tests. - They take in terms of
millisecondsto run and are the fastest of all the tests. - If we follow architectural patterns like
MVVM,MVP, We can encapsulate the business logic inpresenterorViewModel, and then in the constructor of thepresenterandViewModelwe can provide the android framework dependent dependencies. - Now when testing them we can just
MOCKthese dependencies and test the business logic that depends on the dependencies in the constructor. - We write all these tests in the
/testfolder of android. - We can use
J-Unitsoftware to write unit tests. - We can test the
presenterorview-modelbecause there is a interface seperating the view and the model -
[VIEW]<->Interface<->[Presenter/ViewModel]<->Interface<->[Model]
- One specific indicator for identifying the
device testsalso calledInstrumentation testsis the need forcontext. -
Contextis needed to access any of the resource of a android device. - The need of the use of
Asset-Manager,Sqlite-Database, all depend on the Instrumentation test - It needs time to run, because the apk need to be installed on the
device/emulatorand need to be run. - Instrumentation also involves performing the
touch,click,typingactions on the application. - It involves
activities,fragmentswhich are visual UI emements. - We can use
espressoto runUI tests