-
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 computation
that involves things like thebusiness logic
. - We can use the
unit test
for these types of tests. - We can literally write
thousands
of these types of tests. - They take in terms of
milliseconds
to run and are the fastest of all the tests. - If we follow architectural patterns like
MVVM
,MVP
, We can encapsulate the business logic inpresenter
orViewModel
, and then in the constructor of thepresenter
andViewModel
we can provide the android framework dependent dependencies. - Now when testing them we can just
MOCK
these dependencies and test the business logic that depends on the dependencies in the constructor. - We write all these tests in the
/test
folder of android. - We can use
J-Unit
software to write unit tests. - We can test the
presenter
orview-model
because there is a interface seperating the view and the model -
[VIEW]
<->Interface
<->[Presenter/ViewModel]
<->Interface
<->[Model]
- One specific indicator for identifying the
device tests
also calledInstrumentation tests
is the need forcontext
. -
Context
is 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/emulator
and need to be run. - Instrumentation also involves performing the
touch
,click
,typing
actions on the application. - It involves
activities
,fragments
which are visual UI emements. - We can use
espresso
to runUI tests