Retrofit 2 – Mocking HTTP Responses

Retrofit 2 – Mocking HTTP Responses

In the previous post, I discussed implementing a custom Retrofit Client to mock out different HTTP response codes. This mechanism works well for Retrofit versions 1.9 and below but has its drawbacks. After trying out Retrofit 2, I have adjusted the previous sample and managed to achieve the same results (with some improvements 😀).

Mocking API Responses using a Retrofit Client in Android (Retrofit 1.9)

Mocking API Responses using a Retrofit Client in Android (Retrofit 1.9)

Writing test cases in Android can be quite a daunting task, especially the handling of different server responses. Testing error responses can be quite problematic and your app might not cover all the different scenarios. If you are using Retrofit 1.9 and below to do your network calls, testing error responses can be quite simple. There …

Read More Read More

Android Data Binding – Part 2

Android Data Binding – Part 2

In Part 1 I gave an introduction into the Android Data Binding Library. I suggest reading that post first before reading further. In this post I am going to discuss the following : Binding Adapters Binding Events Two Way Binding Binding Adapters Creating an adapter and using Android Data Binding for each item is quite simple. …

Read More Read More

Getting Started: The Android Data Binding Library Part 1

Getting Started: The Android Data Binding Library Part 1

Anyone who has dabbled a bit in Android Development will know that Android is lacking a key component of MVVM: The ability to bind data without a couple of lines of code.  For instance, setting a TextView to some value retrieved from a server is pretty complex, considering the simplicity of the task:

Doing everything …

Read More Read More