Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Testing and securing android studio applications

You're reading from  Testing and securing android studio applications

Product type Book
Published in Aug 2014
Publisher Packt
ISBN-13 9781783988808
Pages 162 pages
Edition 1st Edition
Languages

Chapter 10. Supporting Tools

In this chapter, you will learn about the external tools different from those available in Android Studio that will help us test our Android applications. The chapter will cover test tools to perform unit and functional tests. It will also cover tools that help us secure our application in different ways. We will end this chapter with an alternative tool that allows you to emulate an Android device.

The topics that are going to be covered in this chapter are:

  • Tools for unit testing Android applications

  • Tools for functional testing Android applications

  • Tools for securing Android applications

  • Some other tools

Tools for unit testing


As we have seen in Chapter 9, Unit and Functional Tests, unit testing is performed with minimal connection to the system infrastructure and tests the different components in isolation. We will see different tools that allow us to easily perform unit tests on Android applications. They are as follows:

  • Spoon

  • Mockito

  • Android Mock

  • FEST Android

  • Robolectric

Spoon

Spoon is not a new form of unit testing. Instead, it makes use of the existing unit testing instrumentation such as JUnit to run tests on multiple devices. With Spoon, you can test your application on many devices at the same time. When the test is completed, you will receive a summary generated by Spoon with all the information regarding the test performed on the devices. You can also use Spoon for functional testing.

For a device to be considered by Spoon to run tests on, it has to be visible to the Android Debug Bridge (adb) devices. You can even perform the tests on different types of devices at the same time, such...

Tools for functional testing


In Chapter 9, Unit and Functional Tests, you learned how functional tests are performed with full connection to the system infrastructure. In this section, we will look at the different tools that allow us to easily perform functional tests in Android applications:

  • Robotium

  • Espresso

  • Appium

  • Calabash

  • MonkeyTalk

  • Bot-bot

  • Monkey

  • Wireshark

Robotium

Robotium runs on the official Android testing framework. It adds the necessary features to run through an entire Android application. It has full support for both native and hybrid applications.

Now, we will see the steps needed to run a test using Robotium on our Android application:

  1. Add the Robotium JAR to your Build Path.

  2. Create a test case using the JUnit TestCase class.

  3. Write the test case code.

  4. Run the test case.

Tests with Robotium are performed using the com.robotium.solo.Solo class available in the Robotium library.

We will now see an example of the white-box testing using Robotium. In this example, we have two EditText fields:...

Other tools


In this last section, we will see a tool that is not directly related to application testing or security testing. However, it can significantly improve our testing experience.

Genymotion

Genymotion is an alternative and unofficial Android emulator. It is basically a virtual emulator that creates a virtual image of Android and is often considered much faster than the official Android emulator. It is available for Windows, Linux, and Mac OS. If you are using Windows or Linux, you only need to install the Genymotion distribution package. However, if you are using Mac OS, you need to download and install VirtualBox manually. The following is a screenshot captured from the virtual device manager that lists all the virtual devices available:

Note

If you want to get started with using Genymotion, you can visit our blog: http://belencruz.com/2014/01/first-look-at-genymotion-android-emulator/. To download and learn more about Genymotion, visit the project website: http://www.genymotion.com...

Summary


In this chapter, you learned about the external tools that help us perform tests on our Android applications. The chapter covered several automated unit testing tools and several automated functional testing tools. You also learned how to stress test our applications using Monkey and what tools we will need if we want to check the network connectivity of our application. An alternative Android emulator that is in most cases faster than the official one was reviewed too.

In the next chapter, which is the last chapter, you will learn about some tips that are very useful for developers. You will also learn how to get help in case you need it.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Testing and securing android studio applications
Published in: Aug 2014 Publisher: Packt ISBN-13: 9781783988808
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}