Back to Resources

Blog

Posted May 12, 2022

Getting Started with Automated Testing

Well-implemented automated testing improves test coverage, increases execution speed, and reduces the manual effort involved in testing software. Automated testing is also referred to as test automation or automated QA testing.

Automated testing is a software testing technique that leverages automation technologies rather than human testers to control the execution of tests. The actual test findings are then compared to the expected outcomes. Your projects will be more efficient and have a shorter time to market if you use automated testing.

Benefits of Test Automation 

Many software companies across the globe are embracing automated software testing for their SaaS products. The following are some of the many advantages of automated testing:

  • Simplifies testing: Automation testing simplifies the typical software testing routine and operations in tech companies by using automation test tools and test scripts that can be reused for different test cases. Unlike in manual testing (where every single line of testing code must be written and executed), automated testing scripts are easily customizable for different use cases.

  • Speeds up the testing process: Automated tests shorten software development cycles because automation tools and machines are faster than humans. This way, the testing phase of the SDLC is faster and more accurate.

  • Reduces the risk of human error: Automation testing can be run at any time of the day without human intervention. It also increases the accuracy level because it reduces the risk of human error due to manual testing.

  • Saves time and money: In the long run, automation testing is more cost-effective and time-saving compared to manual testing, which takes longer and requires paying staff to do work that machines can do. Plus, automation frees employees to focus on other tasks like designing new functionality that can increase revenue.

  • Improves bug detection: Automated testing provides wider coverage for analyzing and detecting bugs that humans might not be able to see during manual testing.

  • Comprehensive reporting capabilities: Automated tests provide extensive visibility into testing reports through dashboards and insight views which are not possible with human tests. These detailed automation test reports give developers and business teams an in-depth analysis of the SaaS product, its functionality, and what needs to be done to improve it.

  • Reliability: Automation testing is less likely to cause errors – hence, it is more reliable.

  • Parallel testing: Automated tests can be run on multiple devices at the same time, which is impossible with manual testing. This increases the volume of tests that you can do within a given timeframe and shortens the test cycle dramatically when large tests can be carved up into smaller (atomic and autonomous) test cases that are run in parallel.

  • Information Security: The effectiveness of testing is largely dependent on the quality of the test data provided as input to the automation tool. Using a good automation tool will ensure the security of the test data when manipulating, creating, and protecting the test database (which manual testing does not achieve in most cases).

Test Automation Pyramid

The test automation pyramid is a testing strategy for mobile applications and websites where tests are automated across a mix of user interface (UI), API or integration (service), and unit testing. While every project, system, and delivery team are unique, generally that mix should appear as a pyramid.

The “Test Pyramid” concept was created by Mike Cohn and has been written about by thought leaders across the industry. The automation test pyramid (illustrated below) flips the original test pyramid by placing unit testing at the base followed by API or integration (service) and then UI testing.

Test Automation Pyramid

Test Automation Test Cases

In software testing, a test case is a detailed document containing specifications, input, steps, testing conditions, and expected outcomes related to the execution of a software test on a particular application. Every feature in a SaaS product involves two test cases – a positive and a negative test case – to produce the desired coverage in different scenarios in the test suite. The following are some of the test cases that can be automated:

  • Regression tests: Automation testing is ideal for sanity or smoke tests because they require significant human resources and are time-consuming.

  • Performance tests: To perform stress and load testing on the application, automated tests repetitively query the desired coverage, which is tedious and time-consuming when done manually.

  • Data-driven tests: Automation tests use input data to analyze the SaaS product and minimize human error.

  • Unit tests: Automation testing supports unit tests due to their reusability and low maintenance costs.

  • Functional tests: Automation testing can also test whether frameworks and development codebases meet the desired specifications.

  • Integration tests: Automation testing helps identify integration faults and provides a reliable way of ensuring robustness between different modules and interfaces.

Test Automation Strategy

The success of automated testing is determined by the testing strategy: you must create a test automation plan that identifies the initial set of test cases (these will serve as the groundwork for future tests) and the testing tools you’ll be using.

Choosing the right automated testing framework for your organization is one of the keys to mastering test automation. Another tool to choose is the testing tool itself: will you use emulators or real devices? Will you buy all the devices, or will you use a comprehensive cloud-based testing platform?

More automated testing resources:

Best Practices for Automated Testing

There are a few best practices to remember when implementing an automated testing strategy: 

  • Choose the right test automation framework for your needs: There are many options, so take the time to decide which covers your use cases.  An automated testing tool such as Cypress, Playwright, TestCafe, Webdriver.io, Puppeteer, or Selenium will enable your team to become fully automated throughout your CI/CD pipeline.

  • Use manual testing when necessary: Manual testing is an important part of the testing process as well. Even if your team moves completely to automated testing, manual testing is still something you might need for debugging purposes.

  • Emphasize a culture of digital confidence: When thinking about automating your testing process, a greater responsibility as a company is to think about creating a culture of digital confidence. Acknowledging the need for digital confidence as a company is important as a best practice for automated testing because it creates an end goal for the application of a great user experience.

How to Choose Which Tests to Automate

Not all tests should be automated, but most unit, integration, and performance testing can be easily automated. Consider the following criteria when deciding which tests to automate:

  • High value and business critical: Tests that ensure your app keeps running smoothly and uninterrupted, such as smoke tests, sanity tests, and regression tests.

  • High volume, repeatable, and/or tedious: Tests scripts that are time consuming or need to be repeated many times, such as testing different browser/OS combinations and running high-volume batch tests.

  • Predictable results: Tests that are both repeatable and have predictable outcomes, such as stress tests and load tests.

  • Frequently used functionality: Tests frequently used functionality that comes with high-risk conditions for both the device and sensitive user data, such as loss of functionality (e.g., loss of data connection), unexpected high data usage, battery draining 2-3 times faster than normal, and security or privacy exposure.

  • Impossible to perform manually: Tests that can’t be performed manually. For example, a manual test may return an issue that you’re unable to diagnose. Automated tests can not only identify an issue but also indicate the cause of the issue.

  • Test data and environments: Tests that automate tasks like setting up environments and test data.

Automated Testing Tools

Deciding which automated testing tools to use can often be a pivotal, make-or-break point in any CI/CD initiative. It’s important to understand the differences in the types of tools you can choose for automated testing.

There are three categories of tools that you and your team might consider when beginning the journey to automated testing:

  • Test creation: The tool you will use to write your automation tests, such as Selenium or Appium.

  • Test management: The tool you will use to capture requirements, design automated test cases, and collaborate across teams.

  • Test execution: The infrastructure you will use to run tests across every required browser, operating system, and device. You can choose to build your own infrastructure from scratch, or, more optimally, you can choose a fully hosted cloud-based testing platform.

Popular Test Automation Frameworks

The market offers a plethora of test automation frameworks to choose from, and the decision isn’t always easy. As you evaluate mobile testing frameworks to determine what's suitable for your organization, you should ask some key questions to help uncover your needs and understand the impact of a new tool on your organizational processes, tech stack, and teams.

The following are popular test automation frameworks:

  • Selenium - Selenium is the industry standard in open-source automated testing framework for web applications. Selenium WebDriver is a great starting point for teams moving from manual testing to automated testing because of its breadth of coverage with client drivers. Selenium WebDriver is essentially language agnostic and allows for automation testing in languages such as JavaScript, Java, C#, Ruby, and Python, among others. 

  • Appium - Appium is a leading open-source test framework that allows for cross-platform (mobile) native test automation, as it supports both iOS and Android platforms. It was derived from Selenium to extend automated testing functionality to mobile apps.

  • XCUITest - XCUITest is the testing framework that ships with Apple’s XCode development system, and as such, it is the most popular framework for performing basic unit-level testing of iOS apps.

  • Espresso - Espresso is the testing framework that comes built into Android Studio and is designed specifically for functional testing of Android applications.

  • WebdriverIO - WebdriverIO  (not to be confused with Selenium WebDriver, which supports only browser testing) is a JavaScript test automation framework for both browser and native mobile testing. WebdriverIO is best for organizations that have extensive and broad testing needs that extend beyond just basic JavaScript tests.

  • Cypress - Cypress is a JavaScript testing framework that can perform both front-end and (to a certain extent) backend testing. Cypress is a good choice for developers who use JavaScript (or Node) for both server-side and client-side development.

  • TestCafe - TestCafe offers the advantage of supporting both JavaScript and TypeScript as the languages for writing testing scripts. TestCafe is an excellent choice for testing any desktop or mobile JavaScript apps, provided they are client-side only. If you need server-side testing support or mobile testing, look elsewhere.

  • Playwright - Playwright, released by Microsoft in January 2020, is open source, and is one of the newest JavaScript-based test automation frameworks available. Playwright is an attractive choice for developer-friendly, cross-browser testing that supports multiple languages, including but not limited to JavaScript. But if you need to test for Internet Explorer, you’ll need a different framework. You may also want to wait a bit for Playwright to mature further if you are worried about having to handle rapidly changing APIs.

  • Puppeteer - Puppeteer is a great alternative to the newer and less stable Playwright. Puppeteer is the go-to test automation framework for developers who only need to support Chrome and Chromium. For cross-browser tests, frameworks like Playwright provide a similar experience.

  • Detox - Detox is an open-source JavaScript-based test framework for React Native applications. It works cross-platform, accepts tests written in JavaScript, and works well with emulators and simulators. Detox is designed for gray box testing, allowing monitoring of the app from the inside, and is known to reduce test flakiness as it is well synchronized with the app’s activity.

  • EarlGrey - EarlGrey is an open-source iOS UI automation framework developed by Google. It supports only iOS and hence requires tests to be written in Objective-C or Swift. Some benefits of EarlGrey include easy integration into iOS, simplicity in writing tests, and enhanced built-in synchronization features which help to increase test stability. 

More information on choosing a test automation framework:

Test Automation Process

The test automation process is the same across tools and includes the following basic steps:

  1. Prepare the test environment: Establish a base state for the test environment that includes a realistic data set and one or more configured environments. This base state is what the system returns to after testing.

  2. Run the test script: Test automation tools run the tests automatically according to the test case.

  3. Analyze the test results: Review the log to see if any bugs were identified. You can also run the test again manually if needed.

Automated Testing with Selenium

Selenium is an open-source testing framework that has found wide adoption in recent years. Selenium testing supports the most popular scripting languages, including Node.js, Java, Python, PHP, Ruby, or C#. Test scripts can be produced with the languages known best. Developers, QA, and even project managers can develop and review tests for all apps, speeding up the time to market.

Benefits: As the most widely used testing platform, Selenium is the most well-supported and comprehensive app testing framework available. As an open-source platform, Selenium leverages the expertise of a huge community. Selenium also has bindings for many scripting languages like Ruby, .NET, C#, JavaScript, and even Cucumber. This allows your Dev teams to manage and review your tests in whatever language you choose to further reduce testing time. 

Some limitations to be aware of: Selenium is only for desktop web applications and cannot be used to test mobile applications. In addition, some testing capabilities are impossible to automate with Selenium, such as randomly generated elements like CAPTCHA (however, many well-documented workarounds can help overcome this blocker). As tests become longer and more involved, you may notice a deprecation in execution speed. By following a few Selenium best practices, you can help mitigate that risk. In fact, some may see this as a benefit of using Selenium, as it requires developers and testers alike to practice writing high quality code and tests to ensure there are no quality bottlenecks in the pipeline. Finally, Selenium doesn’t have a reporting feature out of the box or a way to upload feature files out of the box initially. However, this capability can be done with a cloud-based testing platform.

Generally speaking, Selenium’s flaws are extremely specific and most teams looking to start out with automation will find Selenium’s flexibility and scalability make it the best choice for automating web testing.

Selenium resources:

Automated Testing with Appium

Appium is a leading open-source test framework that allows for cross-platform (mobile) native test automation, as it supports both iOS and Android platforms. It was derived from Selenium to extend automated testing functionality to mobile apps.

Benefits: Since it's built on the same JSON wire protocol, QA and development professionals who are familiar with Selenium will find the transition to Appium easy. Its extra functionality allows for testing of native, mobile web, and hybrid apps, and can be run across both the iOS and Android operating systems. Appium tests are language-agnostic, and users do not need to install any extra software on their mobile device to support Appium. Backed by a large and thriving community, Appium users get consistent support for troubleshooting their issues.

Some limitations to be aware of: Users who are new to Appium need to familiarize themselves with a new scripting language and learn the rules on how to best interrogate your application to see the benefits of automated testing. Also, to optimally utilize the power of Appium for native app testing, users need to learn the concepts of native app/ selectors and have a reasonable understanding of the Appium architecture, which adds to the learning curve.

Appium resources:

Need to test right now? Get started free.

Ship code that behaves exactly as it should.

© 2023 Sauce Labs Inc., all rights reserved. SAUCE and SAUCE LABS are registered trademarks owned by Sauce Labs Inc. in the United States, EU, and may be registered in other jurisdictions.