When it comes to implementing a sound software QA approach, there’s probably nothing more important than testing. The problem is that software testing is such a vast area. With many terms and buzzwords, types of testing, and tools, it’s hard not to feel overwhelmed. Today’s post is our contribution to relieving your burden by supplying you with detailed information about one specific test-related topic: UI test automation.
“UI test automation” is a term that has become somewhat loaded over time. Different people might assign it very different meanings. To add to the confusion, there is (some) disagreement on whether UI testing is something worth pursuing at all. Well, the good news is that we’re here to clear that up for you. After reading this post, you’ll better understand what UI testing is, why it’s essential, and how it fits into a modern QA strategy. Before wrapping up, we share a list of best practices you can start adopting today to get the most out of your UI testing approach.
UI Test Automation: Fundamentals
Defining UI Test Automation
UI testing can be defined as the process of verifying an app’s user interface not only behaves as intended but also empowers users to get their tasks done efficiently. Through UI testing, we can, among other things:
- visually check an app’s UI isn’t jarring or unintuitive;
- examine whether input from users is handled correctly, including invalid input;
- ensure that there are no spelling mistakes, capitalization inconsistencies, or even debugging messages that made it to production;
- review for readability/legibility problems, including font size and colors.
More interesting though, is the discussion around whether you should perform UI testing or not, how it fits into a modern QA strategy, and whether to automate or not.
Why Perform UI Testing?
After having defined UI test automation, we have to take a step back and argue in favor of UI testing. This is necessary because there are people who think UI testing isn’t worth the trouble and that unit tests and integration tests are all you need. Let’s see why we believe that such a statement is misguided.
Unit Tests Are Not Enough
First, you have to understand why unit tests, even though they’re necessary, are not sufficient for your QA approach because, in a sense, they’re not really tests. Think of unit tests more as executable sanity checks that programmers write to validate their assumptions when writing code.
However, unit tests aren’t a faithful representation of the application in real usage. That’s because they verify only small pieces (aka “units”) in complete isolation. Instead of dealing with real external dependencies, they rely on techniques such as mocking. This property of unit tests is a double-edged sword: It allows the tests to be simple and fast. But at the same time, there’s a whole category of defects that unit tests can’t catch.
Integration Tests Aren’t Enough Either
Integration tests address the limitations of unit tests by actually testing the integration between different units and between the units and the external dependencies, such as the database, the filesystem, the network, and so on. Some people go on to say that you should write mostly integration tests.
Integration tests, in a way, are the opposite of unit tests. They’re costly to write and set up and slower to run, and they require you to erase all of their traces after each test execution in order not to mess with the next test run. However, they represent a more realistic scenario and, as such, can catch defects that happen at the integration between different layers of the application.
You could say that unit tests and integration tests complement one another. One’s weaknesses are the other’s strengths and vice versa. However, this dynamic duo alone still can’t carry the whole burden of a QA approach. Why is that?
The UI is What the User Sees and “Touches”
UI testing is essential because the UI is the face of the application. It’s also often the face of your brand and your organization’s reputation. Testing approaches that ensure the app works at the API level are undoubtedly valuable. Letting an interface that’s weird, buggy, inaccessible, or hard to understand and navigate reach your customers is a sure way to turn them into former customers.
UI testing caters to all of that, in a way that API-based forms of testing cannot. That’s why UI testing is worth your time. But does it need to be automated?
The Importance of Automation in Software Testing
From 1 to 10, how important is automation in software testing? We’d say that it’s an 11.
Make no mistake: manual testing is far from dead. Picking the right balance between manual and automated testing is essential to ensure you have a successful QA approach.
However, there’s just no way to deliver software at the speed the modern world requires by relying on a testing approach that’s completely manual. That’s due to this thing called regression and the fact that software, more than any tangible product, is amazingly prone to it. Since every change made to a codebase, no matter how seemingly insignificant it is, can cause problems in any other part of the application, you can say you’re confident in the quality of the code you’re releasing only if you thoroughly test the whole application after every change.
Doing so manually would require such an absurd amount of time and resources that you might as well give up on testing entirely. That’s why the road to fast and high-quality software delivery has to go through automated tests.
Where Does UI Testing Fit in Your QA Approach? The Test Pyramid, Revisited
Up until now, we have established that, although unit tests and integration tests are valuable, so is UI testing. A good testing strategy will balance these types of tests along with other testing, like performance and load testing, grid testing, and the list goes on. How can we figure out how UI testing fits into this puzzle?
The test pyramid concept might give us some guidance. In his famous article, Martin Fowler describes the test pyramid as “a way of thinking about how different kinds of automated tests should be used to create a balanced portfolio.” Throughout the article, Fowler points out that a well-balanced testing strategy should employ a more significant number of unit tests than any other type of test because of the reason you’ve already seen in this post. He also goes on to mention the weak points of UI tests, especially their lack of reliability. He’s right, of course: tests that drive the application through its UI can be fragile since they often fail due to changes to the interface.
However, it’s been many years since the publication of that article. And while the test pyramid is undoubtedly a useful concept, it’s crucial to note that, nowadays, we have tools that can make UI tests more reliable, making test maintenance easier. Testim is one such tool. This AI-powered solution can analyze the DOM of web pages, creating smart locators for each element. That way, even when developers change the attributes of those elements, the tests continue to find and test the functionality of the element.
UI Test Automation Best Practices
Before parting ways, we’ll share some best practices for your UI test automation you can adopt right away.
- Don’t rely solely on UI testing. We said earlier that it’d be a mistake to disregard UI testing and to think that all you need are unit tests. The opposite also applies. UI testing is valuable, and so are other types of testing, since each one can’t do the job of the others.
- Do automate the tests you can. Not every test can be automated. Exploratory testing will reveal visual problems or unnatural behaviors that unfamiliar users might encounter.
- Don’t test all possible tests in all target browsers. Instead, investigate which test cases really require testing in different browsers and then employ a grid testing tool.
- Do consider a risk-based approach. Targeting your UI testing at areas that change more frequently or are more bespoke from an engineering perspective, can help you maximize your testing resources.
This list of best practices is by no means exhaustive, but it can help you get started on your UI test automation journey.
Fun and Profit With UI Test Automation
There are many types of software testing, automated or manual. In today’s post, we’ve covered UI test automation. You’ve seen how UI test automation is neither the only type of software test you need nor the waste of time the naysayers claim it is. Instead, it’s a cog in an overall well-engineered QA machine. A very valuable one, since the UI is the face of the application. You’ve learned that UI testing is no longer synonymous with fragile tests, due to modern tools that leverage machine learning to create reliable results.