LoginSignup
0
0

More than 5 years have passed since last update.

FBSnapshotTestCaseでUIImageのテストを行う。

Last updated at Posted at 2018-11-30

はじめに

FBSnapshotTestCaseはUIViewのレイアウトをテストするライブラリですが、以下のカテゴリーメソッドを追加する事によってUIImageのテストも行う事ができます!


extension FBSnapshotTestCase {

    func FBSnapshotVerifyImage(_ image: UIImage, identifier: String = "", suffixes: NSOrderedSet = FBSnapshotTestCaseDefaultSuffixes(), tolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line) {
        FBSnapshotVerifyView(UIImageView(image: image), identifier: identifier, suffixes: suffixes, tolerance: tolerance, file: file, line: line)
    }

}

実際の呼び出し例は以下の通りです。

   var image: UIImage!

  UIImageの生成処理

   ...(テストコード)

  FBSnapshotVerifyImage(image)

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