Test Attributes and Wrangle UIKit Descriptions
Next, let’s add a test to confirm the attributes of the username text field. But testing every single attribute is overkill. Let’s only test the attributes we changed from their default settings. Add a test named test_usernameField_attributesShouldBeSet. Copy and paste the content of the outlet test, except for its assertions. Then add the following assertions and run the tests:
| let textField = sut.usernameField! |
| XCTAssertEqual(textField.textContentType, .username, "textContentType") |
| XCTAssertEqual(textField.autocorrectionType, .no, "autocorrectionType") |
| XCTAssertEqual(textField.returnKeyType, .next, "returnKeyType") |
The tests ...
Get iOS Unit Testing by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.