5 Implementing consumer-driven contract testing for mobile clients

 

This chapter covers

  • Pact Consumer Setup for Android Apps
  • Android consumer test implementation
  • Android consumer contract generation

Chapter 4 covered consumer-driven contract testing for web clients using Pact version V3. However, if you are a mobile developer or tester, you will want to understand how to implement consumer-driven contract testing (CDCT) in your native language. In this chapter, we will use Kotlin and Gradle to walk through the implementation steps of CDCT in an Android-native application using Pact version V4, from setting up the interaction and applying best practices to generating the consumer contract.

If you have a strong understanding of the foundational concepts from chapter 3, it's time to start implementing contract testing. In our experience of working with mobile applications within a microservices environment, it’s important to take care of external APIs interacting with the mobile app. Mobile apps are released in a bundled version at a point in time but not every user updates the app at the same time. Good coverage around the contracts is key to providing a seamless experience for the user.

5.1 Pact consumer setup for Android apps

 
 

5.1.1 Requirements

 
 
 
 

5.1.2 Mobile app implementation

 

5.2 Android consumer test implementation

 
 

5.3 Android consumer contract generation

 
 

5.3.1 Pact matchers

 

5.3.2 Pact POST requests

 

5.4 Chapter exercises

 
 
 

5.5 Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest