Maximize Appium Testing with a Real Device Cloud

Maximize Appium Testing with a Real Device Cloud
Jessica Manheimer
  March 16, 2023

The average person spends about four hours a day on their phones, according to eMarketer, and 88% of that time is spent in apps. Since the Apple App Store’s launch in 2008, the mobile app market has become fiercely competitive, with more than 2.5 million apps on Google Play and nearly two million on the Apple App Store.

Mobile app popularity and increasing competition make testing critical to ensure quality and reliability. After all, about half of users will delete an app after a single crash, and the same percentage will avoid poorly performing apps. Fortunately, mobile testing has become a lot easier with Appium and cloud-based device labs.

This article will examine how Appium works, some best practices to remember, and how to use real devices for the most accurate results.

Appium is a popular way to automate mobile tests, but device clouds are essential to get the most value.

What is Appium?

Appium is an open-source test automation framework for native and hybrid mobile applications. With support for multiple programming languages and testing frameworks, it offers a versatile way to interact with mobile apps through its user interface and verify functionality. Testers can even capture screenshots and perform visual comparisons. In essence, Appium provides a wrapper that translates Selenium WebDriver commands into UIAutomation (iOS) or UIAutomator (Android) commands. That way, you can execute native, hybrid, or mobile-web app tests on mobile devices regardless of their operating system without including an SDK or recompiling your app – making running and scaling tests easier than ever.

Here’s an example of an Appium JavaScript:


const webdriverio = require('webdriverio');

const opts = {
  port: 4723,
  path: '/wd/hub',
  capabilities: {
    platformName: 'Android',
    platformVersion: '9',
    deviceName: 'Android Emulator',
    app: '/path/to/app.apk',
    automationName: 'UiAutomator2',
    appPackage: 'com.example.app',
    appActivity: 'MainActivity'
  }
};

const client = webdriverio.remote(opts);

client.init().then(function () {
  return client
    .click('#login-button')
    .setValue('#username', 'myusername')
    .setValue('#password', 'mypassword')
    .click('#submit-button')
    .waitForExist('#welcome-message', 5000)
    .getText('#welcome-message')
    .then(function (text) {
      console.log(text); // outputs: "Welcome, myusername!"
    })
    .end();
})
.catch(function (err) {
  console.error(err);
});


In this example, the opts object contains the configuration information for the Appium server running on port 4723. You can easily modify the same test to run across different mobile devices by updating the capabilities part of the opts object. Multiple tests can run on the same Appium server – even in parallel to improve throughput.

How to Test Mobile Apps

Mobile app testing is a complex process that involves writing tests at multiple levels. While past testing involved manual testers compiling each release and running through a series of steps, automated tests run these tests with each commit, merge, or deployment without extra effort. As a result, they’re a lot more scalable than manual tests.

The most common tests include:

  • Unit Tests – Developers typically write unit tests for individual functions within a mobile app to catch bugs at the code level.
  • Integration Tests – Integration tests ensure different components of an app, such as third-party APIs or databases, work together.
  • UI Tests – UI tests use Appium and frameworks like Selenium to interact with an app’s UI to ensure it works as expected.
  • Performance Tests – Performance tests ensure an app performs well across different network speeds or device types.
  • Acceptance Tests – Acceptance testing involves testing the app from a user’s perspective to ensure it meets high standards.

When running these tests, most organizations use test management solutions to execute automated tests and coordinate bug fixes. For example, you might use Zephyr Squad to manage tests within Jira, run them with a Jenkins server, and create new issues for any bugs. That way, keeping your entire team on the same page is easy.

5 Mobile Testing Best Practices

Good testing practices are essential to building an effective and efficient mobile test suite. By following best practices, you can ensure your test suite provides accurate and reliable test results to help you catch bugs earlier and improve your mobile app’s quality.

Test on Real Devices

Simulators and emulators have a place in mobile testing, but real devices can help expose issues that may not be apparent in virtual environments. For example, you can identify issues related to device-specific features, such as a camera or GPS, and you can more accurately evaluate factors like battery consumption, signal strength, or resource usage.

Scale with Cloud Testing

Maintaining a device lab is an expensive and time-consuming endeavor. You must purchase (and regularly update) devices, support them with software updates, and manage the physical environment and power requirements. With a cloud-based device lab like BitBar, you can access a broad range of devices without the management or CapEx overhead.

Use Realistic Test Data

Mobile tests should use test data reflecting real-world scenarios. For example, if you’re testing a photo upload capability, use a photo with a realistic file size to see how long it takes. An excellent way to gather accurate test data is to record live data and anonymize it for testing purposes. That way, you’re using the same inputs as customers.

Test Network Conditions

Mobile apps are often at the mercy of cellular networks. So, when testing mobile apps, it’s essential to simulate lifelike network conditions to understand how users will likely use the app. For example, in our photo upload example, you could constrain bandwidth to actual mobile network conditions (e.g., 3G) to assess performance.

How to Scale with BitBar

BitBar makes it easy to scale mobile tests with an extensively cloud-based device lab. Rather than building and maintaining a device lab, you can connect Appium tests to the BitBar Cloud to run client-side tests against remote devices or use server-side execution to host your tests on BitBar’s servers and access the results.

bitbar-cloud-client-side-server-side-test-execution

Appium can run in client-side or server-side modes based on your requirements.

In addition to running standard tests, BitBar supports advanced testing of native device features. For example, BitBar’s Beta biometrics instrumentation makes it easy to test applications using biometric identity authentication via fingerprints or faces. You can also access cloud-based devices for ad-hoc testing or debugging specific issues.

For even more advanced UI tests, BitBar pairs with VisualTest to automatically identify and flag changes in visual appearance. These capabilities can help you spot changes to the UI that may not throw an error in code-based UI tests. For instance, a typical example might be a misaligned item that still appears on a screen and passes tests.

The Bottom Line

Mobile app testing is essential to ensure apps function correctly across various devices and platforms. While there are many mobile testing platforms, Appium has become one of the most popular open-source options, providing a unified API for testing iOS and Android apps. And it’s even more powerful when using real devices via BitBar.

If you’re looking for a way to scale your mobile tests, start a free trial to see how easy it is to execute mobile tests in the cloud on real devices.

You Might Also Like