This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import XCTest | |
import MapKit | |
class ExampleTests: XCTestCase { | |
//declaring the ViewController under test as an implicitly unwrapped optional | |
var viewControllerUnderTest : ViewController! | |
override func setUp() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
@testable import UnitTests | |
class ExampleTests: XCTestCase { | |
var viewControllerUnderTest: ViewController! | |
override func setUp() { | |
super.setUp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <XCTest/XCTest.h> | |
#import "FerryTerminalAnno.h" | |
#import <CoreLocation/CoreLocation.h> | |
#import <MapKit/MapKit.h> | |
@interface FerryTerminalAnnoTest : XCTestCase | |
@property (nonatomic, strong) FerryTerminalAnno *annoUnderTest; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)testFetchingFoursquareVenues { | |
//create a semaphore with initial value | |
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); | |
NSURL *url = [NSURL URLWithString:@"https://api.yourawesome.com"]; | |
NSURLSessionDataTask *task = [self.session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { | |
XCTAssertNil(error, @"NSURLSessionDataTask returned completed with Error: %@", error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import <XCTest/XCTest.h> | |
#import "SightingReport.h" | |
#import "SightingReport+CoreData.h" | |
#import "AppDelegate.h" | |
@interface SightingReportTest : XCTestCase | |
//for accessing CoreData NSManagedObjectContext in assertions | |
@property (nonatomic, strong) AppDelegate *appDelegate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import <XCTest/XCTest.h> | |
#import "AppDelegate.h" | |
#import "Item.h" | |
#import "Item+CoreData.h" //note: Item+CoreData is a category for the Item entity (i.e. NSManagedObject subclass) | |
@interface Item_CoreDataTest : XCTestCase | |
//for accessing CoreData NSManagedObjectContext in assertions | |
@property (nonatomic, strong) AppDelegate *appDelegate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ViewController.h" | |
#import <HealthKit/HealthKit.h> | |
@interface ViewController () | |
@property (nonatomic, strong) HKHealthStore *healthStore; | |
@end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For removing the separator line indentation from a UITableViewCell | |
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) { | |
if(tableView.respondsToSelector("setSeparatorInset:")) { | |
tableView.separatorInset = UIEdgeInsetsZero | |
} | |
if(tableView.respondsToSelector("setLayoutMargins:")) { | |
tableView.layoutMargins = UIEdgeInsetsZero | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example of an asynchronous unit test | |
func testUserLogin() { | |
let readyExpectation = expectationWithDescription("ready") | |
User.loginWithUsername("[email protected]", password: "blah") { (isSuccess) -> Void in | |
let expectedLoginSuccessStatus = true |