MockWebServer is a scriptable web server for testing HTTP clients implemented by Square and written in Java. In this case, we are going to use a test double known as mock and a third party tool known as MockWebServer. To test if the API client is working as expected, we need to use test doubles and perform assertions over the information sent through the network. In order to validate these 3 keys assumptions, we need to simulate different server side responses and perform assertions over the client side request. - Implementing the authentication mechanisms properly.- Sending the correct messages to the API.When dealing with server side API integrations, we need to know if our client’s side code is: Testing the integration with a server side API If your application uses authentication then it is even more important to test the API integration, because the application is useless if the authentication fails. We need to ensure that our code is sending the right data to the API and correctly parsing the API responses. However, the integration with an external service is one of the key points in the application development. In 2016, majority of the Android/iOS applications are only a front-end to display information obtained from a service as well as cache or persist some data. Without these services, applications simply can’t work. This remote service, or API, is used to retrieve information and persist data. Most of the mobile applications are based on a server side API. In this blog post, we will review several testing approaches that cover the second part of our Testing Development Pipeline under the theme “how to test our integration with a remote service”. That is why it will be way more interesting to write in most of the test scenarios. - Tests based on state and not interaction between components are less coupled to implementation details.- The Dependency Inversion Principle will help replace production code easily using test doubles.- Test doubles can also be used to verify collaboration between components.- Test doubles are required to simulate the behaviour of different components and to choose the scope of the test in order to create isolated test environments.We discussed how to use the Dependency Inversion Principle as a key principle to test our code and reached the following conclusions: In our previous blog post, “World-Class Testing Development Pipeline for Android - Part 2”, we talked about testing our business logic aka, “the first part of our Testing Development Pipeline”. Pedro Gómez 18 January 2016 World-Class Testing Development Pipeline for Android - Part 3
0 Comments
Leave a Reply. |