spring-cloud-contract icon indicating copy to clipboard operation
spring-cloud-contract copied to clipboard

How to use stubs on mobile development (Android / Swift)?

Open jabrena opened this issue 4 years ago • 11 comments

Hi,

In some scenarios, native developments like Android/IOS could be considered like other Consumers from Contract testing perspective for a REST API.

Using Spring cloud contract is possible to run a Docker image connecting the image with some Stubs published in Artifactory/Nexus but it is necessary to create some Ops operations in order to run/maintain that images. https://github.com/spring-cloud/spring-cloud-contract/tree/master/docker

Do you know some toolset to run docker images for Android & IOS in the Dev environment?

Many thanks

Juan Antonio

jabrena avatar Aug 28 '19 12:08 jabrena

You've pointed to a wrong repo https://github.com/spring-cloud/spring-cloud-contract/tree/master/docker

marcingrzejszczak avatar Aug 28 '19 12:08 marcingrzejszczak

Upgraded the link

jabrena avatar Aug 28 '19 13:08 jabrena

a Docker image connecting the image with some Stubs published in Artifactory/Nexus

Sorry, that doesn't make any sense for me, could you rephrase?

So, what problems do you encounter running stubs for Android/IOS? I am also planning to do the exact same thing but I haven't tried yet. I imagine that mobile devs can just use the docker stub runner to run the stubs during their testing and I don't really see anything else to be done.

Sam-Kruglov avatar Sep 10 '19 06:09 Sam-Kruglov

Hi @Sam-Kruglov

Yes, I was reviewing the project/documentation and maybe in the Documentation and in the Samples area, the project should have a section about How to use for mobile applications in the future.

Why: En mobile applications, you could consider a native development as another consumer of API stubs to guarantee that contracts doesn't change in the time. The lack of JSON schema is not only affected for others Microservices, the mobile development has the same impact. This is the reason.

In an Android, I am going to test with testcontainers-java in order to load the docker image to load the stubs in a POC: https://github.com/spring-cloud/spring-cloud-contract/tree/master/docker

But in IOS, I am not sure if exist something to load Docker images. (I am reviewing)

In the other hand, the documentation in this area is not extensive: https://cloud.spring.io/spring-cloud-contract/reference/html/using.html#flows-provider-non-jvm

This is the reason for this issue.

Juan Antonio

jabrena avatar Sep 11 '19 08:09 jabrena

Thanks for the insight @jabrena! I have engaged our IOS team to investigate that. We're going to do it next week. I will post here what we find.

Sam-Kruglov avatar Sep 12 '19 07:09 Sam-Kruglov

Hey, just had a chat with IOS. They decided against WireMock for these reasons:

I have not researched what WireMock does. It’s nothing to do with being good enough. It does not fit into our CI as we are not running unit tests against HTTP server. And I don’t see the need to run contract tests against HTTP stack. I guess it could be useful for mocking API responses during development, but as I said, different teams/developers already use different tools for that. Some have their own mock server, some use CharlesProxy with local mapping, and iOS used to have something written in NodeJS also.

But they also were familiar with this presentation on Pact and we noticed that Spring Cloud Contract actually has some integration with it. So, that is what we are going to investigate next. The first thing I've read is that using Pact, Spring Cloud Contract can generate the tests and stubs, so should be fine with backend.

Sam-Kruglov avatar Sep 18 '19 14:09 Sam-Kruglov

I have not researched what WireMock does. It’s nothing to do with being good enough. It does not fit into our CI as we are not running unit tests against HTTP server. And I don’t see the need to run contract tests against HTTP stack.

That's an interesting response since Pact does exactly the same thing AFAIR (but maybe I'm wrong).

marcingrzejszczak avatar Sep 18 '19 14:09 marcingrzejszczak

Thanks, @marcingrzejszczak, I've stressed your point.

Sam-Kruglov avatar Sep 19 '19 09:09 Sam-Kruglov

Hi, I am creating a Pilot for IOS & Android about the topic. Lets see how evolve

jabrena avatar Jan 21 '20 16:01 jabrena

I couldn't get much traction on contract testing, nobody is doing anything. We are also migrating to graphql, so might not even be relevant

Sam-Kruglov avatar Jan 21 '20 16:01 Sam-Kruglov

Tomorrow, I will send the proposal for SpringIO including this topic.

jabrena avatar Feb 21 '20 17:02 jabrena