Skip to content

k3po/k3po.ios

Repository files navigation

K3PO for iOS

Build Status Issue Stats Issue Stats

Objective-C based Network Protocol Testing Framework

Building this Project

Minimum requirements for building the project

  • Xcode 5 or higher
  • Xcode's Command Line Tools. From Xcode, install via Xcode → Preferences → Downloads.
  • xctool: brew install -v --HEAD xctool

Steps for building this project

  1. Clone the repo: git clone https://github.com/k3po/k3po.ios.git
  2. Go to the cloned directory: cd k3po.ios
  3. Build the project: xctool -project K3poControl.xcodeproj -scheme Framework

K3poControl.framework will be available under build/framework folder.

Using K3poClient in XCTestCase

In a class that extends XCTestCase, a test method can use K3poClient as shown below:

#import <K3poControl/K3poControl.h>
...
...
- (void) testK3poClient {
    BOOL success = YES;

    // This can be moved into setup method.
    K3poClient *k3poClient = [[K3poClient alloc] initWithScriptRoot:@"org/kaazing/specification/ws/opening"];

    @try {
        [k3poClient prepare:@"connection.established/handshake.response"];

         // Code to initialize WebSocket and connect goes here.

         // XCT assertions generate failures and not exceptions. This means that they cannot be caught using
         // @catch. Also, XCTest does not offer any other mechanism to figure out whether there was any failure
         // while executing Client library calls. Till XCTest becomes more extensible, we will have to live with
         // this workaround. This will allow us to pass either YES or NO into K3poClient's finish selector.
    }
    @catch (NSException *ex) {
        success = NO;
    }
    @finally {
        [k3poClient finish:success];
    }
}