iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🔥
Viewing Xcode Test Reports
Create the following test code in Xcode (the code provided is borrowed from "iOS Test Guidebook").
import XCTest
func validate(password: String) -> Bool {
if password.count <= 7 {
return false
}
let numString = password.components(
separatedBy: CharacterSet.decimalDigits.inverted).joined()
return numString.count >= 2
}
class PasswordValidatorTests: XCTestCase {
func testパスワードバリデーションの文字数() {
XCTContext.runActivity(named: "数字が2文字以上含まれている場合") { _ in
XCTContext.runActivity(named: "合計7文字が入力された場合") { _ in
XCTAssertFalse(validate(password: "abcde12")) }
XCTContext.runActivity(named: "合計8文字が入力された場合") { _ in
XCTAssertTrue(validate(password: "abcdef12"))
}
XCTContext.runActivity(named: "合計9文字が入力された場合") { _ in
XCTAssertTrue(validate(password: "abcdefg12"))
}
}
}
}
Executing the test with ⌘U generates a Test Report containing the test results. The test report can be viewed from the following location.

Environment used in this article
- Xcode 12.5
Bonus
The content shared in this article was introduced to me during a regular reading group session held at shu223's salon (we are currently reading the "iOS Test Guidebook").
Discussion