Test Automation Best Practices
We’ve already talked about the benefits of test automation. This article is about typical use cases/test scenarios for automated testing.
But first things first: there are a number of things to consider when starting to automated tests and one of them is to decide which tests should be and can be automated. That’s why we created this guide on test automation best practices.
Test automation best practices – Which test cases should be automated?
A test case or use case scenario is a simulated situation in which a user performs determinate actions when using a particular app. Some typical test cases can be automated and it would be a very good idea to do so to save money, time and keep users as happy as possible!
Depending on your app, you may want to write specific test scripts for certain features and actions. Nonetheless there a few criteria to decide which tests to automate and these are test automation best practices.
1. Automate the most frequent test-cases
There may already be a number of tests that you’re manually running as routine tests to check basic functionality on different devices and after every minor update.
Those tests might be a good start for test automation since they are executed repeatedly and running them manually might lead to errors, such as forgetting a step, so that the results might not be reliable.
Above all performing repetitive test is time-consuming and extremely boring, so don’t let the talent of your testers get wasted on something a script can do better.
2. Automate test cases that are easy to automate
Automated test cases that are easy to automate to have positive results on your ROI: it will take a little time to write effective scripts that will save time and money in the long run.
3. Automate test cases that have predictable results
You can automate test with conditional actions, which have predictable results e.g. if you click on the icon, the app must be launched.
Those kinds of tests, which state the obvious are not obvious at all. There are apps which pass every in-app test, but when a user tries to launch it, nothing happens.
4. Automate the most tedious manual test cases
Manual testing can be tricky at times, that’s when automated testing get his big spotlight.
Software testing is always tricky but it becomes even trickier when it comes to mobile app testing. Every device is different and every manufacturer changes Android a little bit to personalize it, so manual testing can become tedious and complicated.
Luckily for us, we can automate those tests so to get the exact and right information that we need to know about our app.
In conclusion: automate generic processes as much as possible so that you have time to look in detail into issue and bugs. No app is going to be perfect, but you can try to get as close as possible because end-users are unforgiving people!
5. Automate test cases that are impossible to perform manually
Some tests cannot be performed manually, i.e. you maybe can perform them manually, but you just see that something isn’t working, but you don’t know why.
Performing an automated test, in this case, can also indicate the cause of a certain action/series of actions not working. Again saving time, saving money and boosting your ROI.
6. Automate test cases that run on several different hardware or software platforms and configuration
With today’s device fragmentation, testing on as many devices as possible is of the most important things to do before making the debut in the app market. So writing tests that can be run on different devices, from different manufacturers, on different OSs and OS versions will save you a great amount of time.
7. Automate frequently used functionality
Frequently used functionalities come often with high-risk conditions, for both the device and sensitive user data. Without proper testing, apps might have negative effects on the end-user device, such as:
- Loss of functionality ( e.g. loss of data connection)
- Unexpected high data usage
- Battery draining 2-3 times faster than normal
- Security or privacy exposure.
Some apps ask more permission than actually necessary and data leakage can cause unwanted and unnecessary exposure of the user’s data.
Decide which test cases to automate
Every test has its own place in the testing process. The majority of test can be automated, but there are a few tests that need to be performed manually.
This graphic gives you an overlook of what should be tested when during an apps’ life cycle.
The success of automated testing is determined by the testing strategy: you must create a test automation plan, identifying the initial set of test cases (that will serve as the groundwork for future tests) and the testing tools you’ll be using.
Frameworks are an important tool to choose: there are many different kinds of automated UI testing frameworks and it might get really confusing. But choosing the right one is one of the keys to mastering test automation.
Another tool to choose is the testing tool itself: will you be using emulators or real devices? Will you buy all the devices or will you be using a remote online cloud service?
After having set the agenda and found everything you need, the real work begins. What action will your automated tests perform?
Try to keep your tests as easy and short as possible. There is no sense in writing a test which is large, complex and difficult to edit and to debug. Small and logic are the recurring keywords.
You can put all the pieces together later, grouping them, but making sure that every small part is working properly. You can also write test as you develop the app, instead of finishing one thing and then starting with the tests.
Test automation is all about saving time, so finding bugs and issues early in the app code, makes sure that it will a quick fix, or at least there is not that much code to check.
When grouping tests, you create test suites; when testing an app you can run the whole suite or you can specify which tests in the suite you do not want to run in a specific test cycle.
Tests can be organized by functional area, major/minor division in the application, common function or set of test data. Tests can also be run randomly or you can specify the order in which the tests are performed.
What to keep in mind when running automated tests
Automated test scripts must be maintainable and updatable easily when changes are needed. Test automation is all about running test in less time.
Try to write tests that can run smooth and give reliable test results even if the UI changes, especially in the first stages of the app. Test do sometimes rely on object’s coordinates; if the object changes place, the test can no longer be performed because the object to be tested can no longer be found.
That’s why you should provide unique names/labels for your controls: this makes your test resistant to UI changes and assures that your tests will run no matter what changes in the UI. Location based tests are more unstable and break easily.
Regression test for compatibility are very important as well: device and OS fragmentation have to be taken into account when updating apps. Regression tests are meant to check if the recently made changes have broken something that was working before, not only on the latest device with the latest OS version but on older devices with older OS versions as well.
Automated testing is now more important than ever before: app’s updates have to be released faster to the market, making app development a continuous development process. Tools for continuous integration are designed to help you keep track of bugs and issues as you go.
Whether automated or manual, mobile app testing should be done in the right way.
And without test automation, you’ll be soon out of the game!
TEST MORE, WORRY LESS!
- Accessibility Testing
- Appium Resources
- Best Practices
- Continuous Delivery
- Continuous Integration
- Continuous Testing
- Cross Browser Testing
- Guest Blog Posts
- Load Testing
- Machine Learning
- Mobile Development & Testing
- News & Product Updates
- Open Sauce
- Open Source
- Performance Testing
- Product Updates
- Quality Assurance
- Quality Engineering
- Sauce Product Info
- Security Testing
- Selenium Resources
- Software Development & Testing
- The Story of Sauce