简体   繁体   中英

Android black-box testing (no access to app code). Is Google's Espresso a good choice?

I have recently been looking in to Espresso , which looks for me very promising.

I am recently working in an Android test project, and we are recently using Espresso as we see some benefits with that. Unfortunately the setup in the company I work for is such that I do not have access to the entire code for the Application we are testing.

So how I can create a test using android studio?

You can use UIAutomator to get the ids of various views. See here

With view ids you can perform assertions/click and other actions on them

An example

onView(withId(R.id.play_search_container)).perform(click());

Hence you can go through the whole UI flow by clicking on various elements.

if you want to write a test outside of application's code, I mean: pure black-boxing, Espresso would be a pretty hard to implement as it needs a bit of application architecture (the same thing is with Robotium or `UiAutomator): names of Activities, views texts, contentDescriptions or idies.

You can use instead of Espresso :

The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner.

  • monkeyrunner (requires Python language programming basics)

The monkeyrunner tool provides an API for writing programs that control an Android device or emulator from outside of Android code. With monkeyrunner , you can write a Python program that installs an Android application or test package, runs it, sends keystrokes to it, takes screenshots of its user interface, and stores screenshots on the workstation. The monkeyrunner tool is primarily designed to test applications and devices at the functional/framework level and for running unit test suites, but you are free to use it for other purposes.

Calabash is a framework that enables Automated UI Acceptance Tests written in Cucumber to be run on iOS and Android applications. Calabash works by enabling automatic UI interactions within an application such as pressing buttons, entering text, validating responses, etc.

From: Introduction to Calabash

Hope it will help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM