Skip to content

Instantly share code, notes, and snippets.

@kozy4324
Last active October 11, 2015 13:07
Show Gist options
  • Select an option

  • Save kozy4324/3863375 to your computer and use it in GitHub Desktop.

Select an option

Save kozy4324/3863375 to your computer and use it in GitHub Desktop.
SenTestingKitめも

ロジックテスト、アプリケーションテストの切り替え

ロジックテストに切り替え

「Build Settings」から「bundle loader」と「test host」の値を削除

アプリケーションテストに切り替え

「Build Settings」から「bundle loader」に

$(BUILT_PRODUCTS_DIR)/<app_name>.app/<app_name>

を入力、「test host」に

$(BUNDLE_LOADER)

を入力

マクロ

無条件の失敗

STFail(failure_description, ...)

等値比較

STAssertEqualObjects(object_1, object_2, failure_description, ...)
STAssertEquals(value_1, value_2, failure_description, ...)
STAssertEqualsWithAccuracy(value_1, value_2, accuracy, failure_description, ...)

STAssertEqualObjectsは[object_1 isEqualTo:object_2]で比較される

Nilテスト

STAssertNil(expression, failure_description, ...)
STAssertNotNil(expression, failure_description, ...)

ブールテスト

STAssertTrue(expression, failure_description, ...)
STAssertFalse(expression, failure_description, ...)

例外テスト

STAssertThrows(expression, failure_description, ...)
STAssertThrowsSpecific(expression, exception_class, failure_description, ...)
STAssertThrowsSpecificNamed(expression, exception_class, exception_name, failure_description, ...)
STAssertNoThrow(expression, failure_description, ...)
STAssertNoThrowSpecific(expression, exception_class, failure_description, ...)
STAssertNoThrowSpecificNamed(expression, exception_class, exception_name, failure_description, ...)
STAssertTrueNoThrow(expression, failure_description, ...)
STAssertFalseNoThrow(expression, failure_description, ...)

コマンドラインからテスト実行

xcode4.5で確認。sdkをiphonesimulator6.0にするとARCHSがi386でhogehogeするのでVALID_ARCHSを指定している。

$ xcodebuild -target <app_name>Tests -configuration Debug -sdk iphonesimulator6.0 VALID_ARCHS=i386 TEST_AFTER_BUILD=YES clean build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment