Last active
August 29, 2015 14:03
-
-
Save hironytic/6df7a8e203f5f26fb337 to your computer and use it in GitHub Desktop.
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/UIKit.h> | |
| #import <XCTest/XCTest.h> | |
| @interface ObjCExp1Tests : XCTestCase | |
| @end | |
| @implementation ObjCExp1Tests | |
| - (void)setUp { | |
| [super setUp]; | |
| // Put setup code here. This method is called before the invocation of each test method in the class. | |
| } | |
| - (void)tearDown { | |
| // Put teardown code here. This method is called after the invocation of each test method in the class. | |
| [super tearDown]; | |
| } | |
| // test doesn't fail. | |
| - (void)testFail1 { | |
| __block BOOL called = NO; | |
| dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
| XCTFail("failed"); | |
| called = YES; | |
| }); | |
| [NSThread sleepForTimeInterval:3]; | |
| XCTAssertTrue(called, "called"); | |
| } | |
| // test does fail as expected. | |
| - (void)testFail2 { | |
| XCTestExpectation *expectation = [self expectationWithDescription:@"fail2"]; | |
| dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
| XCTFail("failed"); | |
| [expectation fulfill]; | |
| }); | |
| [self waitForExpectationsWithTimeout:5.0 handler:nil]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment