test ios UnitTest and UITest

Overview

github_actions

Bundlerの導入

  • fastlaneやiOSパッケージマネージャであるCocoaPodsはRubyのライブラリ
  • 開発チームで使用するバージョンを揃えるためにBundlerを導入する

bundlerのインストール

gem install bundler

Gemfileを生成(リポジトリには生成済)

gem install bundler

Gemfileにライブラリを追加して、gem install

bundle install
bundle info XXXX --> DLしたライブラリのバージョン確認

CI

UnitTestの導入

  • XXXXTest.swiftという形でUnitTestのファイルを追加する
  • @testableでモジュールインポートを忘れずに!!
  • testYYYYと「test」でメソッドを始めること
  • command shift U でテストを実行する

強制unwrapはNG

  • 失敗された位置が記録されない
  • 強制アンラップ以降のコードが実行されない
  • XCode上の操作ではテストの実行が停止してしまう

独自のAssertionを作成する場合

  • 以下の例のように現在実行中の「lineとfile」を渡してください。
  • そうしないと本来下記のメソッドで表示したいエラーの位置が呼び出し元になってしまいます。
空文字判定の独自Assert

func assertEmpty(_ string: String, file: StaticString = #file, line: UInt = #line) {
  XCTAssertTrue(string.isEmpty, "¥"¥(string)|" is not empty", file:file, line:line)
}

呼び出し時
func testAssertEmpty() {
  let string = "hello"
  seertEmpty(string)
}

テスト結果の抽出

  • XCode11以前はxccovを使って.xccovreportの中身を確認していたようです
  • XCode11以降はxccresultというファイルの中身を確認します。参考1参考2
$ xcrun xccov view --report ResultBundle.xcresult

slatherを導入する

gem install slather
bundle install
  • XCode13ではSlatherがうまく動かない・・・泣

GithubAction workflow

mac-os

  • latestだと最新にならない可能性あり(最新でないと利用できるXCodeのバージョンに差分が出るので注意)

シミュレータの起動

  • 現状うまくいかない。-> 一旦後回し中。

UITestの導入

-> 一旦後回し中。

CD

fastlaneを導入

xcode-select --install・・・実行してない人のみ(インストール済みの場合はエラー発生するが無視してOK)
sudo gem install fastlane -NV
fastlane init ・・・ここで利用目的に応じてfastlaneの設定方法が選べる
  • fastlane/にファイルが作成
  • Appfileは、AppleIDなどを記述するファイル
  • Fastfileは。自動化するタスクを記述するファイル
You might also like...
iOS UI Automation Test Framework

Deprecation: EarlGrey 1.0 is deprecated in favor of EarlGrey 2.0 which integrates it with XCUITest. Please look at the earlgrey2 branch. EarlGrey 1.0

A collection of useful test helpers designed to ease the burden of writing tests for iOS applications.
A collection of useful test helpers designed to ease the burden of writing tests for iOS applications.

MetovaTestKit is a collection of useful test helpers designed to ease the burden of writing tests for iOS applications. Requirements Installation Usag

Alef Dev Test iOS

AlefDev тестовое задание iOS Задача Разработайте экран, где человек может заполн

Rapptr iOS Test Jimin Kim

Hello! Your task is to use the provided project to create the iOS app displayed

Mooviely - Mooviely Basic App for IOS Test

Mooviely Mooviely Basic App for IOS Test. Anasayfa Bu sayfa açıldığında ekranın

Monkey Test Tool For iOS

CrashMonkey Japanese About This is a tool of monkey test(random operation test) for iOS applications. Please watch the demo movie. CrashMonkey uses UI

The XCTest Project, A Swift core library for providing unit test support

XCTest The XCTest library is designed to provide a common framework for writing unit tests in Swift, for Swift packages and applications. This version

Test Library for Swift's Error Handling

CatchingFire CatchingFire is a Swift test framework, which helps making expectations against the error handling of your code. It provides for this pur

This is a simple test app getting data from network to practice a tad bit.

test This is a simple test app getting data from network to practice a tad bit. Start Nothing fancy, no CocoaPods, just clone and run! Architecture Ju

Owner
SUGY
SUGY
An good example for UITest In swiftUI

SwiftUI_UITest A good example for UITest In swiftUI contains: UI test for swiftUI fake Web service for UI Test 'launch Environment' for use Fake Servi

hosein 2 Jan 12, 2022
Kfm-ios-test - Test online for iOS Developer position in Kimia Farma or PT. Buana Varia Komputama

kfm-ios-test Kimia Farma Mobile iOS Test Test online for iOS Developer position

Erwindo Sianipar 3 Feb 23, 2022
Test-To-Do-List - Test To Do List with core data

test-To-Do-List This is my first pet project with core data Launch screen Main s

Artem 0 Feb 26, 2022
Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers!

OHHTTPStubs OHHTTPStubs is a library designed to stub your network requests very easily. It can help you: test your apps with fake network data (stubb

Olivier Halligon 4.9k Dec 29, 2022
BDD Framework and test runner for Swift projects and playgrounds

Spectre Special Executive for Command-line Test Running and Execution. A behavior-driven development (BDD) framework and test runner for Swift project

Kyle Fuller 392 Jan 1, 2023
I built this application with unit testing and test-driven development to understand TDD theory and practice

TestDrivenDevelopment Description I built this application with unit testing and test-driven development to understand TDD theory and practice, to wri

null 1 Dec 21, 2021
This repository accompanies Test-Driven Development in Swift: Compile Better Code with XCTest and TDD

Apress Source Code This repository accompanies Test-Driven Development in Swift: Compile Better Code with XCTest and TDD by Gio Lodi (Apress, 2021). D

Apress 57 Jan 1, 2023
Test task application based on Swift using CoreData, Alamofire, AlamofireImage and CocoaPods

iTunes Search Test task application based on Swift using CoreData, Alamofire, AlamofireImage and CocoaPods Features ?? Searching music albums by name

Alexander Zhukov 0 Oct 31, 2021
iOS Test Hasitha

Welcome to the Bidone iOS Coding Test! iOS Create a simple application with the list of orders from viewModel and display them in a list. When a user

null 0 Nov 12, 2021
iOS Test for Openbank by David Moreno Lora

MarvelMobileTest-iOS iOS Test for Openbank by David Moreno Lora Installation Clone the project and install the dependencies using pod install Once th

David Moreno Lora 0 Nov 16, 2021