Hi folks :wave:, in this post I’m going to cover a new swift package I’ve been working on recently, mountebankSwift.

This is a new swift package I’ve created recently to help out with testing my LiveTramsMCR project recently, as I’ve been looking to use mocks to test how the app responds to different API responses.

I decided to use mountebank for this as I have a good bit of experience testing APIs using mountebank, as I’ve used the MBDotNet package with C#, which I’d highly recommend you check out as it’s a great piece of work.

When I tried to find a swift client to work with mountebank however, there didn’t appear to be any public packages that would allow me to interact with mountebank from in swift. I decided to use this opportunity to create my own package for this, as I’ve been wanting to do more swift development outside of iOS apps.

Creating a package for this will also allow this to be re-used across multiple projects, and hopefully also help other people out along the way.

What are the aims for the package

The primary aim for the package is to support the basic functionality of mountebank. This includes:

  • Creating imposters and stubs to represent a service / API.
  • Retrieving requests made to the mock endpoints
  • Standard operations for tearing down mocks / cleaning up after being used

Whats currently supported

Currently you can:

  • Create HTTP stubs / imposters with / without request or response bodies
  • Retrieving all created imposters
  • Retrieve created imposters (Currently only supports HTTP)
  • Remove created imposters

Where is this package available

The package can be found:

Whats coming soon

The next main addition will be mock HTTP endpoints. These will keep all of the useful information for stubs together, and also make it easier to get the requests made to that mock endpoint.

There will also be more helper methods created, particularly building on the mock endpoints.

Creating request and response bodies will also be made simpler through extra helpers to convert from the object format into the json string required by mountebank.