Test Driven Development iOS
…
TDD
The Life Cycle of TDD
Step 1. 

Step 2.
.
.
.
Step 1. 

Step 2.
Step 1. 

Step 2.
func ( : Int, : Int) -> Int
func ( : Int, : Int) -> Int {
return +
}
Step 1.
func () {}
func () {
let ( , ) = (1, 2)
}
func () {
let ( , ) = (1, 2)
let = ( : , : )
}
func () {
let ( , ) = (1, 2)
let = ( : , : )
XCTAssertEqual( , 3)
}
Step 2.
func ( : Int, : Int) -> Int {
return +
}
TDD
Document
?
?
?
1.
2. QA
2. QA
3. ( )
3. ( )
4.
*
2
Unit Test Integration Test
Integration Test
: www.appcoda.com
Unit Test
*No dependency
?
1. Unit Test
2. CI
3.
4.
Unit Test = No Dependency
“ ” ?
protocol API {}
protocol API {
func (id: String, callback: (String) -> ())
}
class : API {}
class : API {
func (id: String, callback: (String) -> ()) {
}
class : API {
func (id: String, callback: (String) -> ()) {
// Alamofire request (Dependency)
}
}
class : API {
func (id: String, callback: (String) -> ()) {
// Alamofire request (Dependency)
// callback(" ") or callback(' ")
}
}
Mock
class : API {}
class : API {
func (id: String, callback: (String) -> ()) {
}
}
class : API {
func (id: String, callback: (String) -> ()) {
callback(" ")
}
}
func () {}
func () {
let = ()
}
func () {
let = ()
. (“BL1988”) { in
}
}
func () {
let = ()
. (“BL1988”) { in
XCTAssertEqual( , " ")
}
}
func () {
let = ()
. (“BL1988”) { in
XCTAssertEqual( , " ")
}
}
TDD
:
.
) REST API
Swift Mock
: https://github.com/Brightify/Cuckoo

Mock
: http://sinonjs.org/

iOS Test Framework
: https://github.com/Quick/Quick

: https://github.com/Quick/Nimble

TDD
XCTest Framework
: https://developer.apple.com/documentation/
xctest/asynchronous_tests_and_expectations/
testing_asynchronous_operations_with_expectations

Clean Code by
.
Source: github.com/bobthedev/let-us-go-tdd

Test Driven Development iOS에 적용해보기