Skip to content
Paul Zabelin edited this page Nov 21, 2013 · 23 revisions

Sealant consists of number of independent classes that help in testing

Generic

BZSpecHelper - general helper class

BZLog.h - collection of debug macros

add to precompiled header file. See example Testable-Prefix.pch

#import <Sealant/BZLog.h>

BZLogCapture - capture log output for testing

NSURLConnection+Sealant.m - prevent accidental network connections in unit tests

ShowCoverage.applescript - Show test coverage in CoverStory. Add following post action to Xcode unit test scheme:

osascript $PROJECT_DIR/Pods/Sealant/Scripts/ShowCoverage.applescript

reset-simulator.applescript - Reset simulator, e.g. before running integration tests. See example in Testable/Rakefile.rb

select-simulator-device.applescript - Select simulator device, e.g. iPhone (Retina 4-inch)

Kiwi matchers

KWNotificationMatcher - matcher to test NSNotifications being posted

[[MPMoviePlayerPlaybackDidFinishNotification should] bePosted:^(NSNotification *note) {
   [note.object shouldNotBeNil];
}];

KWImageMatcher - matcher to test UIImage matches expected image from test bundle

[[myImage should] matchImage:@"expected.png"];

MKNetworkKit sealant and Kiwi matcher

MKNetworkOperation+Sealant.m - prevents accidental network operations in tests

KWNetworkOperationMatcher - Kiwi matcher to verify MKNetworkOperations

it(@"should make get request and process XML response", ^{
    [[network should] receiveHttp:^(NSString *method, NSURL *url, NSDictionary *parameters) {
        [[method should] equal:@"GET"];
        [[parameters should] match:hasEntry(@"user", @"[email protected]")];
        [[[url path] should] equal:@"/ssl/rest/user/details"];
    } andRespond:@"user_details_response.xml"];
    [engine load:user onComplete:^(NSError *error) {
        [error shouldBeNil];
    }];
});

Objection mock injector

BZMockInjector - Kiwi mock for any objects injected by Objection

TestFlight fake implementation

TestFlight.h - alternative Test Flight header that replaces test flight log with debug macro

BZTestFlightStub.m - stub implementation of TestFlight interface that does nothing but logs