Latest 0.1.4
Homepage https://github.com/mokten/StubPlay
License MIT
Platforms ios 11.0, tvos 11.0
Dependencies Swifter
Authors

Summary

Stubplay lets you save http requests and replay them easily

Handles various http responses and includes text, html, json, images, videos and AVPlayer requests

Why?

  • [x] Saves full http request and response
  • [x] Unit tests are easy – no more having to write a bunch of boilerplate code for the network layer
  • [x] Automated UI tests are easy too
  • [x] Audit responses
    1. Server side dev said they didn’t change anything but you can prove they did because you saved the responses
  • [x] Api not ready? That’s ok you can create your own stubs by hand and use them until the api is ready
  • [x] Debug http requests – view requests being saved as responses are being processed
  • [x] Replay customer experiences -> need to upload to your server yourself

Requirements

  • iOS 11.0+ / tvOS 11.0+
  • Xcode 10.2+
  • Swift 5+
  • Cocoapods 1.7+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.7+ is required to build StubPlay

To integrate StubPlay into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'StubPlay'
end

Then, run the following command:

$ pod install

Usage

We recommend enabling stubs as soon as possible – in your main.swift file or App delegate init()

By default: requests/response are saved in the caches/"com.mokten.stubplay" directory.
Everytime the app is run this directory will be cleared out.

Add a reference folder to your app. ie. "Stub/default", this is where your stubs will be read from

import StubPlay

// This will save all requests and responses to the app cache directory
// Start the app and navigate around
// Once you have completed your scenario then copy the files in the cache directory to your reading stub directory "Stub/default"
try StubPlay.default.enableStub(for: ["Stub/default"])

_ = UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, NSStringFromClass(Application.self), NSStringFromClass(AppDelegate.self))

Concepts

  1. Stubbed request / response has 2 files
    1. request+response/rewrite rule file -> json format
    2. response body file -> native format

The response body is in its own file so that it can be easily be used by viewers/editers ie. image, json, text, html, videos

License

StubPlay is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "StubPlay",
    "version": "0.1.4",
    "swift_versions": "5.0",
    "summary": "Save https requests and responses and then replay them later on.",
    "description": "Stub http requests. Saves requests and replays them. Handles various http responses and includes text, html, json, videos, and images",
    "homepage": "https://github.com/mokten/StubPlay",
    "license": {
        "type": "MIT"
    },
    "authors": {
        "mokten": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mokten/StubPlay.git",
        "tag": "0.1.4"
    },
    "source_files": "Source/**/*.swift",
    "platforms": {
        "ios": "11.0",
        "tvos": "11.0"
    },
    "dependencies": {
        "Swifter": []
    },
    "swift_version": "5.0"
}

Pin It on Pinterest

Share This