Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Utilizing Containers for iOS App Testing

DZone's Guide to

Utilizing Containers for iOS App Testing

This post talks about how to use common iOS container components to create clean and secure mobile app testing environments.

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

Container technology has been enabling companies to pack various software components into a single physical package that can be used for various purposes. In mobile app testing, containers are extremely useful and can easily enable clean, secure and scalable test automation with the right set of tools, programming languages, frameworks, and literally any software components that test scripts, automation components, or applications that need a test execution.

Last week, we discussed the benefits of containers for mobile app testing. This week, we’ll take a look at quite typical ingredients for iOS containers and how to use those for iOS test automation.

Software is eating the world,” stated by Marc Andreessen, is a famous quote about the state of the software world expanding over everything. Containers have been in an essential role in this, and containers have become extremely popular for a variety of different use cases.

In a nutshell, containers can enable users to create a clean, portable, and consistent environment for mobile app development, testing, and deployment. We’ve also found it to be the winning concept here at Bitbar to ramp up clean, reusable, and distributable environment for iOS test automation.

Containers for iOS App Testing

One of the greatest things with containers for app testing is the architecture and its nature; it can be quickly ramped up and used for specific use cases. Containers provide a standardized way to divide apps, tools, and other stuff into distributable containers. Breaking software components up this way offers the ability to place them on different physical and virtual components/machines, for use in the cloud or with on-premise solutions. The flexibility provides advantages around components and provides the ability to quickly and easily make consistent packages.

As discussed, containers can incorporate a lot of different things that work as utilities and software components to aid testing and test automation efforts for your mobile apps. So what goes into containers and how does the typical container look with different components? Here is our example:

Example of Software Components in Container

The core tools include all the basic development tools, and in the case of iOS, it can be anything from Xcode to Fuse, Fastlane, and others. And naturally, all components and tools can be placed in containers with multiple versions. When a specific tool version is used, this can be configured in containers as well. Applications built for efficient mobile test automation must include properly built .IPA file and test package.

Programming language support provided with containers is also easy. Just include the installation package as part of the container and script will take care of getting it ready for test scripts, apps, and others. In the case of iOS Objective-C, Swift and some others provide a great foundation for tests.

With Apple products, iTunes or a connector for it can be incorporated into the container as well.

Other dependencies and middleware can help make test automation straightforward and effortless. In this category, some utilities for internet usage, downloading or uploading other components, as well as making certain functional testing capabilities possible, can be included in the container.

One of the greatest things with containers for iOS app testing is that they can be included with a variety of different test automation framework versions. For example, with Appium, we may have several relevant versions for app testing. This may include versions that work with older versions of Xcode as well as with the latest version. Keeping the container up to date with the state of the art iOS app testing components is actually a trivial task.

For example, a container for iOS app testing and test automation could look something like this:

SW included in typical container for iOS App Testing

How to Run Containers Efficiently With Tools and SW

This is always a relevant question when customizing an app testing environment and adding/removing tools or software components from it. Because of clean separation of container components and other software, tests executed inside the container enable users to customize the environment any way they like during the test session. Also, the launch of test automation scripts is easy with container scripts, or even from command line.

This is done by using the run.sh script that is used to launch the the container session. Any shell command or tool that is installed on the container can be called from the run.sh script. For instance, you can build anything with Maven:

mvn clean test –DexecutionType=serverside

-or simply install new additional libraries or tools with Brew, using the following command:

brew install python

To operate efficiently with containers, the run.sh script must be configured; that is basically the force to drive execution of the test environment, tools, and components. Here is an example of the run.sh script:

#!/bin/bash startAppium(){ if [ "$(uname)" == "Darwin" ]; then startAppiumOSX elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then startAppiumLinux else echo "Unknown OS system, exiting..." exit 1 fi } executeTests(){ echo "Extracting tests.zip..." unzip tests.zip if [ "$(uname)" == "Darwin" ]; then echo "Running iOS Tests..." mvn clean test -Dtest=IosAppiumExampleTest -DexecutionType=serverside elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then echo "Running Android Tests..." mvn clean test -Dtest=AndroidAppiumExampleTest -DexecutionType=serverside fi echo "Finished Running Tests!" cp target/surefire-reports/junitreports/TEST-*.xml TEST-all.xml } startAppium executeTests

Containers provide an excellent way to build clean and consistent testing environments for your iOS apps. This blog dealt with a few examples of what can be included in those containers that are eventually executable in the local environment or the cloud. If you are looking for more information about containers or how to run those in our cloud environment, do get in touch.

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:
mobile ,ios ,app testing ,mobile apps

Published at DZone with permission of Ville-Veikko Helppi, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}