surpher / PactSwift

A Swift version of Pact. Implements Pact Specification Version 3.
https://pact.io
MIT License
50 stars 16 forks source link

Feature Request: Any plans for Pact tests generator? #125

Open MikeBenton2 opened 1 month ago

MikeBenton2 commented 1 month ago

Hey y'all, writing all these tests manually suuuuucks which I'm sure a lot of us can agree upon. Especially when you may have a lot of logic in one API call. Are there any plans for generating some of the boiler plate code from an openAPI Spec?

I also posted this request within the other iOS Pact framework: https://github.com/DiUS/pact-consumer-swift/issues/130

surpher commented 1 month ago

That would be fantastic, indeed.

Personally I am not using PactSwift for my/clients' needs at all lately so am limited in expanding features in PactSwift or even just keeping up with pact-foundation's evolution. I've got a backlog of cleanup tasks to do before diving back into improvements.

I'm curious though! Have you had any thoughts about how this would work? I mean, what would developers' experience be?

There's a blog post out there where it describes how they've improved writing pact tests. Unfortunately they didn't make it open source.

Contributions are always welcome.

EDIT: Opened PactFoundation's slack workspace now and found this announcement. Considering what's shared there there should be direction to follow.

MikeBenton2 commented 3 weeks ago

Read the blog post and I'm using Matcher to it's fullest. However, It would have been nice to match it to a Model of a certain type, rather than a literal string, int, bool, etc. Eg.

struct MyModel { var myInt: Int var myString: String }

Matcher.somethingLike(MyModel.Type)

The generation would be a little more tricky, but there's already the OpenAPI Code Generator that my team uses to generate our models and API's so a little inspiration could be taken there. I'm not sure exactly how it would work, but something to keep in mind.