Skip to content

The goal is to be an embedded HTTP Server used for testing. This project is inspired by iOS-FakeWeb and Express.js

License

Notifications You must be signed in to change notification settings

mgchris/CocoaHTTPServerExpress

Repository files navigation

CocoaHTTPServerExpress

The goal is to be an embedded HTTP Server used for testing. The idea is for your test you create an instance of a server, give it a set of conditions to watch for and the response when a condition is met.

Here is a simple testing example:

- (void)testGetStringFromServer {
    
    // Create Manager
    HTTPExpressManager* server = [[HTTPExpressManager alloc] init]; // Create instead of manager (server)
    
    // Connect request and response to server
    NSURL* expectedURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/string.media", [server urlStringForHost]]];
    NSString* expectedString = @"This is what we expect to get back";
    [server connectURL:expectedURL withString:expectedString];
    
    // Test
    NSString* string = [NSString stringWithContentsOfURL:expectedURL encoding:NSUTF8StringEncoding error:nil]; // Make server call
    XCTAssertTrue([expectedString isEqualToString:string], @"Strings do not match! expected: %@  got: %@", expectedString, string);
}

CocoaPods

  1. Add CocoaHTTPServerExpress to your project's Podfile:

    target :MyApp do
    # Your app's dependencies
    end
    
    target :MyAppTests do
      pod 'CocoaHTTPServerExpress', :git => 'https://github.com/mgchris/CocoaHTTPServerExpress.git'
    end
  2. Run pod update or pod install in your project directory.

About

The goal is to be an embedded HTTP Server used for testing. This project is inspired by iOS-FakeWeb and Express.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published