Send notifications directly from your UITesting classes to your running app.
Switch branches/tags
Clone or download
Latest commit 8cb591f Aug 8, 2017
Permalink
Failed to load latest commit information.
Classes device type Jul 9, 2017
.gitignore Initial checkin Nov 4, 2015
HSTestingBackchannel.podspec Release 1.2.1 May 5, 2016
LICENSE Initial checkin Nov 4, 2015
README.md fix readme headlines Aug 7, 2017

README.md

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.

Installation

Install with CocoaPods

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

Usage

  1. use a prefix file and

    #define SNAPSHOT true
    

    (We’re still hoping that snapshot will re-introduce custom build arguments)

  2. In your App Delegate, install the helper

    #ifdef SNAPSHOT
    	#import <HSTestingBackchannel/HSTestingBackchannel.h>
    #endif
    
    (and then in application:didFinishLaunchingWithOptions:)
    
    #ifdef SNAPSHOT
        [HSTestingBackchannel installReceiver];
    #endif
    
  3. Send notifications from your UITesting class

    [HSTestingBackchannel sendNotification:@"SnapshotTest"];
    

or

[HSTestingBackchannel sendNotification:@"SnapshotTest"
                        withDictionary:@{@"key":@"value"}];
  1. Respond to notifications within your app

    #ifdef SNAPSHOT
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(doSomething:)
                                                     name:@"SnapshotTest" 
                                                   object:nil];    
    #endif
    

Bonus - Copy dummy files to the Simulator

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

[HSTestingBackchannel installFilesFrom:@"..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.

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