HSTestingBackchannel 1.3.2

HSTestingBackchannel 1.3.2

LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Aug 2021

Maintained by Confused Vorlon.

  • By
  • Rob

Backchannel for UITesting.

Snapshot is awesome.

Now it uses UI Testing.

UI Testing is massively better than UI Automation - but sometimes, you just want to cheat.

HSTestingBackchannel gives you a simple method to send messages from your UITesting tests directly to your running app in the form of notifications.


Install with CocoaPods

pod 'HSTestingBackchannel', :configuration => ['Debug']


  1. set an 'Active Compilation Condition' in your swift project to define SNAPSHOT


  1. In your App Delegate, install the helper
    import HSTestingBackchannel

And then, in application(_:didFinishLaunchingWithOptions:):

  1. Send notifications from your UITesting class


HSTestingBackchannel.sendNotification("SnapshotTest",with: ["aKey":"aValue"])
  1. Respond to notifications within your app
        forName: NSNotification.Name("SnapshotTest"),
        object: nil,
        queue: .main) { _ in
            //Do Something

Bonus - Copy dummy files to the Simulator

Within a test method (or in setUp), call something like

HSTestingBackchannel.installFiles(from: "..pathTo/fastlane/DummyImages",
                                    to: HSTestingResources)

This will install the contents of DummyImages in the resources folder of your running app. You can also install directly to the Documents directory in the app.

Multiple Simultaneous Simulators

By default, Fastlane now runs multiple simulators simultaneously. This means you need to make sure that the server for each simulator is running on a different test.

Use the setup method to do the following

let app = XCUIApplication()

HSTestingBackchannel.port = UInt.random(in: 8000 ... 60000)
app.launchArguments.append(contentsOf: ["-HSTestingBackchannelPort", "\(HSTestingBackchannel.port)"])

Snapshot.setupSnapshot(app, waitForAnimations: true)


How it works

HSTestingBackchannel installs a webserver in your main app (GCDWebServer).

You simply send requests directly to that - and it recognises them and broadcasts NSNotifications