
When you use an app, you don’t think about all the testing done behind the scenes; you just expect it to work. But for developers and testers, making sure that every tap, swipe, and scroll behaves exactly as intended is a challenge that never goes away.
Most automated tests are unit tests, which test the logic beneath the surface. However, this is much like checking the engine of a car without ever taking it for a drive. By simulating real user interactions, end-to-end user interface (UI) tests let us catch issues that pure code-based unit tests might miss. Compared with traditional automatic tests, UI tests are testing behaviour that is more similar to how the end user will interact with the app. For instance, the Apple library XCUIAutomation for iOS, lets you tap, swipe, and interact with items on the screen as well as test for their presence and text content. Since UI tests are closer to the experience of the end user, the need for manual smoke testing is reduced. Bugs can still be detected before releasing to the end users. Repeating smoke tests is a repetitive process for testers; automating this allows them to focus on exploratory tests that are relevant to new features (with confidence that the other app sections are still functional as expected).
The biggest disadvantage of UI tests is that they can be expensive. When compared with unit tests, they cost more to write, maintain, and run. Most changes to the UI will require that tests be rewritten, and since they are not as isolated as unit tests, this might include updating UI tests from other sections of the app. If this test code is not maintained, the tests will no longer be reliable, and you will lose confidence in them. Since they are more expensive to run, they may be run less frequently, which can lead to issues being found later in the development process (and therefore being more expensive and slower to fix). Additionally, depending on the testing framework used, there are limitations to what the tests are able to check. In the case of XCUIAutomation, the main framework used for iOS, you are able to check the presence, accessibility details, and text content of an individual component. You would still want to rely on manual testing to check other things, such as the size, colour, or icons used.
The best results come from striking a balance. In most cases, there should be significantly more unit tests than UI tests. Unit tests are able to detect most bugs and are a faster and cheaper way of validating apps function as expected. Any business logic should be tested in the unit tests, leaving only the UI to be tested using UI tests. Additionally, the UI tests should be focused on areas that have a stable UI and potentially just the flows that are considered critical to the app. Following these principles will help to minimise the cost of writing, maintaining, and running UI tests, while getting all of the benefits of fast, reliable automated testing.