Testing in Android : Part 4 : Instrumented Unit Test

Instrumented Unit Tests : These are unit tests that run on real devices instead of JVM . Using instrumented Unit Tests, we can have real implementation of an Android Framework component like SharedPreferences objects, context of an Activity etc. Also , we will not have to mock any objects.1.  Add the following Dependencies : androidTestCompile

Testing in Android : Part 3 : Using Mockito

By default , local unit tests are executed against a modified version of android.jar library. This library does not contain any actual code. So, if we make any call to android classes, it will throw an exception. We can use Mocking Framework mockito to mock objects and define outputs of certain method calls. Mockito is

Testing in Android : Part 2 : Using Hamcrest

How to create a simple Unit Test :   Open the application we have used in our last tutorial, create one new class “AdditionTest.java” and add the following method : @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } @Testis used to indicate that this method is a unit test method Now

Testing in Android : Part 1 : Unit Testing

Why Android Unit Testing is used :  Unit testing is used to test each of the smallest testable parts (units) individually and independently . By using unit tests, we can easily verify that logic of the individual units is correct. i.e. we should run unit tests after every build to detect software regressions. For android application