์ฐธ๊ณ ์ฌ์ดํธ ๋ฐ ์ถ์ฒ
์๋ฌธ Kodeco์ iOS Unit Testing and UI Testing Tutorial์ ๋ฒ์ญํ yoonbumatae์ ๊ธ์ ์ ๋ฆฌํ ํฌ์คํ ์ ๋๋ค. ๋ ์์ธํ ๋ด์ฉ์ ์ฐธ๊ณ ํ์๋ ค๋ฉด ์๋ ๋ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ์ธ์!
https://www.kodeco.com/21020457-ios-unit-testing-and-ui-testing-tutorial
iOS Unit Testing and UI Testing Tutorial
Learn how to add unit tests and UI tests to your iOS apps, and how you can check on your code coverage.
www.kodeco.com
Swift(์ค์ํํธ): iOS ๋จ์ ํ ์คํธ(Unit test) ๋ฐ UI ํ ์คํธ ํํ ๋ฆฌ์ผ - BGSMM
์๋ฌธ iOS Unit Testing and UI Testing Tutorial ๋ฒ์ Swift 5, iOS 14, Xcode 12 iOS ๋จ์ ํ ์คํธ(Unit test) ๋ฐ UI ํ ์คํธ ํํ ๋ฆฌ์ผ iOS ๋จ์ ํ ์คํธ๋ ๊ฑฐ์ฐฝํ์ง ์์ง๋ง ํ ์คํธ๋ฅผ ํตํด ์ฑ์ด
yoonbumtae.com
Tutorial
final class BullsEyeTests: XCTestCase {
var sut: BullsEyeGame!
}
- sut๋ System Under Test์ ์ฝ์๋ก์ ํ ์คํธ์ ํ์ํ ๊ฐ์ฒด๋ฅผ ์์ฑํจ
override func setUpWithError() throws {
try super.setUpWithError()
sut = BullsEyeGame()
}
- ๊ฐ ์ ์๋ ํ ์คํธ๊ฐ ์คํ๋๋ฉด setUpWithError๊ฐ ํธ์ถ๋๋ฏ๋ก setUpWithError์์ ํ ์คํธ์ ํ์ํ sut ๊ฐ์ฒด๋ฅผ ์์ฑํด ์ค
override func tearDownWithError() throws {
sut = nil
try super.tearDownWithError()
}
- ๊ฐ ์ ์๋ ํ ์คํธ๊ฐ ๋๋๋ฉด tearDownWithError๊ฐ ํธ์ถ๋๋ฏ๋ก tearDownWithError์์ sut๋ฅผ ํด์งํด ์ค
func testScoreIsComputedWhenGuessIsHigherThanTarget() {
// 1. given
let guess = sut.targetValue + 5
// 2. when
sut.check(guess: guess)
// 3. then
XCTAssertEqual(sut.scoreRound, 95, "Score computed from guess is wrong")
}
- test~ ๋จ์ด๋ก ์์ํ๋ ํจ์๋ฅผ ์์ฑํด์ ํ ์คํธ ์ฝ๋๋ฅผ ์์ฑํด ์ค
- XCAssert๋ก ๊ฐ์ ๋น๊ตํด์ ํ ์คํธ๊ฐ ์ฑ๊ณตํ๋์ง ์คํจํ๋์ง ํ์ธํจ
- ์ฐธ๊ณ : ๊ฐ ์น์
์ค๋ช
- given : ํ์ํ ๊ฐ ์ค์
- when : ํ ์คํธ ์ค์ธ ์ฝ๋๋ฅผ ์คํํจ
- then : ์์ํ ๊ฒฐ๊ณผ๋ฅผ ๊ธฐ์ . XCTestAssertions๋ฅผ ์ฌ์ฉ
'๐ iOS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Unit Test] Test Double (0) | 2023.04.14 |
---|---|
[iOS/Swift] ๋น๋๊ธฐ(async) ํ ์คํธ (0) | 2023.04.14 |
[iOS/Swift] XCTestCase ์์ฑํ๊ธฐ (0) | 2023.04.13 |
[iOS/Swift] Unit Test ๋? (0) | 2023.04.10 |
[RxSwift] passing viewmodel data to viewController (0) | 2023.03.25 |
๋๊ธ