You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// MARK: - Unit test specific properties and methods
extensionSomeViewController{vardateOfBirthErrorString:String{return dateOfBirthComponent.errorMessage
}
Playground
import Foundation
import XCTest
structUser{letname:String}classUserTests:XCTestCase{varuser:User!overridefunc setUp(){
super.setUp()
user =User(name:"Flynn")}func testLoggingIn(){XCTAssertEqual(user.name,"Flynn")}}classTestObserver:NSObject,XCTestObservation{func testCase(_ testCase:XCTestCase,
didFailWithDescription description:String,
inFile filePath:String?,
atLine lineNumber:Int){assertionFailure(description, line:UInt(lineNumber))}}lettestObserver=TestObserver()XCTestObservationCenter.shared.addTestObserver(testObserver)UserTests.defaultTestSuite.run()
How to test a UITableView
classComponent:UIView{vartableView:UITableView!
letminimumIndexPath=IndexPath(row:2, section:0)func testShouldPopulateMinimumPay()throws{
// When
model =makeAdditionalValues(minimumPay:30)
component.model = model
// Then
letcell= component.tableView.cellForRow(at: minimumIndexPath)as!QuickPaymentCellXCTAssertEqual(cell.amountLabel.text,"$30.00")}