Created
September 11, 2014 14:12
-
-
Save nolili/4773bc3f5ccda55cc235 to your computer and use it in GitHub Desktop.
asynchronous unit test
This file contains hidden or 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 | |
| class AsyncTests: XCTestCase { | |
| override func setUp() { | |
| super.setUp() | |
| // Put setup code here. This method is called before the invocation of each test method in the class. | |
| } | |
| override func tearDown() { | |
| // Put teardown code here. This method is called after the invocation of each test method in the class. | |
| super.tearDown() | |
| } | |
| func testExample() { | |
| // This is an example of a functional test case. | |
| XCTAssert(true, "Pass") | |
| } | |
| func testURLConnection () { | |
| let exp = self.expectationWithDescription("test NSURLConnection") | |
| let optionalURL:NSURL? = NSURL(string: "http://noli.li/") | |
| if let url = optionalURL{ | |
| let request = NSURLRequest(URL: url) | |
| NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler: { (response:NSURLResponse!, data:NSData!, error:NSError!) -> Void in | |
| println(response) | |
| println(data) | |
| exp.fulfill() | |
| }) | |
| } | |
| self.waitForExpectationsWithTimeout(10.0, handler: { (error:NSError!) -> Void in | |
| }) | |
| } | |
| func testPerformanceExample() { | |
| // This is an example of a performance test case. | |
| self.measureBlock() { | |
| // Put the code you want to measure the time of here. | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment