LoginSignup
0
0

More than 5 years have passed since last update.

テストターゲット上でアニメーションを切る。

Last updated at Posted at 2018-11-30

はじめに

UI部分のテストは出来るだけユニットテストで行った方が良いです。小回りが効くので。

そのUI部分のユニットテストを行う時、アニメーションを行う処理が入っているとその分処理に時間がかかります。

テスト用にアニメーションの処理を切る処理を入れれば良いのですが、その処理がプロダクションコードのあちこちに紛れ込むのはメンテナンスの観点からよくないでしょう。

幸いな事にiOSにはアプリ全体のアニメーションを切るメソッドがUIViewのクラスメソッド(setAnimationsEnabled)として用意されています!

実際のコード例

実際のコード例を示します。テストターゲット向けのAppDelegate内で書くとプロダクションコードに全く手を入れなくてすみます。

TestingAppDelegate.swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

UIView.setAnimationsEnabled(false)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0