Upgrade to Pro — share decks privately, control downloads, hide ads and more …

New Features of XCTest on Xcode 6

New Features of XCTest on Xcode 6

WWDC2014で発表された、Xcode6のXCtestに追加された新機能について、説明した資料です。

この資料では、以下の項目について説明しています。
* 非同期API
* パフォーマンステスト

Tsuyoshi Yamamoto

July 11, 2014
Tweet

More Decks by Tsuyoshi Yamamoto

Other Decks in Programming

Transcript

  1. Sample for Asynchronous Testing - (void)testDocumentOpening { XCTestExpectation *expect =

    [self expectationWithDescription:@“open”]; ! UIDocument *doc = ...; ! [doc openWithCompletionHandler:^(BOOL success) { XCTAssert(success); [expect fulfill]; } ! [self waitForExpectationsWithTimeout:5.0 handler:nil]; }
  2. Sample for Asynchronous Testing - (void)testDocumentOpening { XCTestExpectation *expect =

    [self expectationWithDescription:@“open”]; ! UIDocument *doc = ...; ! [doc openWithCompletionHandler:^(BOOL success) { XCTAssert(success); [expect fulfill]; } ! [self waitForExpectationsWithTimeout:5.0 handler:nil]; }
  3. Other Expectations XCTestCase+AsynchronousTesting.hʹɺ Convenience APIsͱͯ͠௥Ճ͞Ε͍ͯͨAPI ! - keyValueObservingExpectationForObject: keyPath: expectedValue:

    ! - keyValueObservingExpectationForObject: keyPath: handler: ! - expectationForNotification: object: handler:
  4. APIs for Performance Testing w NFBTVSF#MPDL Ҿ਺ͱͯ͠౉͞Εͨଌఆ༻ͷ#MPDLTΛ ճ࣮ߦ͠ɺ#MPDLTશମͷ  ฏۉ࣮ߦ࣌ؒ

     ࣮ߦ࣌ؒͷ͹Β͖ͭ౓߹͍ʢඪ४ภࠩʣ Λ#BTF-JOFͱൺֱ͠ɺ ςετͷ4VDDFTT'BJMVSFΛධՁ͢Δ ! #BTF-JOFύϑΥʔϚϯεධՁ࣌ͷج४ɻ ɹҎલ࣮ߦͨ͠ςετ݁ՌͳͲΛݩʹઃఆͰ͖Δ
  5. Sample for Performance Testing - (void)testDocumentOpeningPerformance { TestTargetClass *target =

    [TestTargetClass new]; ! [self measureBlock:^{ [target openFile]; [target parse]; [target closeFile]; }]; }
  6. Sample for Performance Testing - (void)testDocumentOpeningPerformance { TestTargetClass *target =

    [TestTargetClass new]; ! [self measureBlock:^{ [target openFile]; [target parse]; [target closeFile]; }]; }
  7. Sample for Performance Testing - (void)testDocumentOpeningPerformance { TestTargetClass *target =

    [TestTargetClass new]; ! [self measureMetrics: [[self class] defaultPerformanceMetrics] automaticallyStartMeasuring:NO forBlock:^{ [target openFile]; [self startMeasuring]; [target parse]; [self stopMeasuring]; [target closeFile]; }]; }
  8. Sample for Performance Testing - (void)testDocumentOpeningPerformance { TestTargetClass *target =

    [TestTargetClass new]; ! [self measureMetrics: [[self class] defaultPerformanceMetrics] automaticallyStartMeasuring:NO forBlock:^{ [target openFile]; [self startMeasuring]; [target parse]; [self stopMeasuring]; [target closeFile]; }]; }