This invention rel
"Celui qui a mis c
A typical conventi
Introduction {#s1}
Travelling is part
Laparoscopic appen
Oakland Raiders NF
Q:
How to remove
The present invent
On this page, you //
// Test_XCTestObservation.m
// BossTests
//
// Created by 孙昕 on 15/12/28.
// Copyright © 2015年 孙昕. All rights reserved.
//
#import
#import "Test_XCTestObservation.h"
@interface Test_XCTestObservation ()
@property(nonatomic,strong)id testObservation;
@end
@implementation Test_XCTestObservation
- (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];
}
- (void)testExample {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
// Create a temporary folder that can be used as the destination of a new download.
NSFileManager *fileManager = [NSFileManager defaultManager];
// Store a reference to the current path.
NSString *tempDirectoryPath = [fileManager createDirectoryAtPath:NSTemporaryDirectory() withIntermediateDirectories:YES attributes:nil error:nil];
// Delete it when we're done.
[fileManager removeItemAtPath:tempDirectoryPath error:nil];
// Make a test observation.
// Don't forget to initialize a new observer every time. The default value should be nil (except in UnitTests).
self.testObservation = [[Test_XCTestObservation alloc] init];
XCTestObservation *testObservation1 = self.testObservation;
XCTestObservation *testObservation2 = self.testObservation;
XCTestObservation *testObservation3 = self.testObservation;
[testObservation1 onTest:self didStartWithInvocation:[NSInvocation invocationWithTarget:testObservation1 selector:@selector(receiveFirstEventFromTestObservation:) object:nil]];
[testObservation1 onTest:self didFinishWithInvocation:[NSInvocation invocationWithTarget:testObservation1 selector:@selector(didFinishWith:error:) object:nil]];
[testObservation2 onTest:self didStartWithInvocation:[NSInvocation invocationWithTarget:testObservation2 selector:@selector(receiveSecondEventFromTestObservation:) object:nil]];
[testObservation2 onTest:self didFinishWithInvocation:[NSInvocation invocationWithTarget:testObservation2 selector:@selector(didFinishWith:error:) object:nil]];
[testObservation3 onTest:self didStartWithInvocation:[NSInvocation invocationWithTarget:testObservation3 selector:@selector(receiveThirdEventFromTestObservation:) object:nil]];
[testObservation3 onTest:self didFinishWithInvocation:[NSInvocation invocationWithTarget:testObservation3 selector:@selector(didFinishWith:error:) object:nil]];
[self waitUntilTestObservationDidFinish];
// Ensure that each of the observers saw the results of the tests.
XCTAssertTrue([testObservation1.receivedFirstEvent boolValue], @"The first test finished");
XCTAssertTrue([testObservation2.receivedSecondEvent boolValue], @"The second test finished");
XCTAssertTrue([testObservation3.receivedThirdEvent boolValue], @"The third test finished");
// If you do NOT want to run more than one test at a time, you can use the property TestExample1/TestExample2/TestExample3 which has onTest:didStartWithInvocation:didFinishWithInvocation:
// Make sure to set the didStartWithInvocation: to nil (as the default value is YES)
[self setTestExample1:nil];
// Set didFinishWithInvocation: as nil
[self setTestExample2:nil];
// Set didStartWithInvocation: as nil
[self setTestExample3:nil];
XCTAssertEqual(testObservation1.lastFailureCount, 0);
XCTAssertEqual(testObservation1.lastError, nil);
XCTAssertEqual(testObservation1.lastExecutionOrder, 0);
XCTAssertEqual(testObservation2.lastFailureCount, 0);
XCTAssertEqual(testObservation2.lastError, nil);
XCTAssertEqual(testObservation2.lastExecutionOrder, 0);
XCTAssertEqual(testObservation3.lastFailureCount, 0);
XCTAssertEqual(testObservation3.lastError, nil);
XCTAssertEqual(testObservation3.lastExecutionOrder, 0);
// Release observation
[testObservation release];
// No need to release
testObservation = nil;
}
@end