Test the Submit Button
The behavior of the Submit button is defined in the changePassword method. This is a big one. The method has 116 lines with three sections. The first section checks the inputs. The second sets up the appearance of the view while we wait for the password call to finish. The third section passes the inputs to the password changer and handles success or failure. Let’s test this, step by step.
Since our tests will be tapping the Submit button, let’s add a helper to TestHelpers.swift to make these tests more expressive:
| func tap(_ button: UIButton) { |
| button.sendActions(for: .touchUpInside) |
| } |
The Submit button interacts with the password changer. We created a MockPasswordChanger ...
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.