首页 > 代码库 > 安卓测试基础(一)

安卓测试基础(一)

Testing Fundamentals

The Android testing framework, an integral part of the development environment, provides an architecture and powerful tools that help you test every aspect of your application at every level from unit to framework.

安卓测试框架,是开发环境的重要组成部分,提供了架构和强力的工具区去帮助你测试应用的各个方面,从单元测试到框架,不同水平的测试.

The testing framework has these key features:

测试框架有下面这些主要功能:

 

  • Android test suites are based on JUnit. You can use plain JUnit to test a class that doesn‘t call the Android API, or Android‘s JUnit extensions to test Android components. If you‘re new to Android testing, you can start with general-purpose test case classes such as AndroidTestCase and then go on to use more sophisticated classes.

  安卓测试套件基于JUnit. 你能使用普通的JUnit区测试不调用安卓API的类.或者安卓的JUnit扩展来测安卓组件,如果你是安卓测试的新手,你能从通用测试用例类,例如AndroidTestCase ,之后使用更多复杂的类.

  • The Android JUnit extensions provide component-specific test case classes. These classes provide helper methods for creating mock objects and methods that help you control the lifecycle of a component.

     安卓JUnit扩展提供了特定组件的测试用例类. 这些类对创建mock objects 和methods提供了帮助,从而帮你控制这些组件的生命周期.

  • Test suites are contained in test packages that are similar to main application packages, so you don‘t need to learn a new set of tools or techniques for designing and building tests.

 测试套件包含在测试保重,与主应用程序包非常类似,所以你不需要去学新的工具或者技术去设计和构造测试.

  • The SDK tools for building and tests are available in Eclipse with ADT, and also in command-line form for use with other IDEs. These tools get information from the project of the application under test and use this information to automatically create the build files, manifest file, and directory structure for the test package.

  SDK的构造和测试的工具在Eclipse的ADT中是可用的,并且在其他IDE中的命令行模式下一样可用.这些工具从被测应用的project中得到信息并且自动用这些信息创建,build files,manidest file和测试包的目录结构.

  • The SDK also provides monkeyrunner, an API for testing devices with Python programs, and UI/Application Exerciser Monkey, a command-line tool for stress-testing UIs by sending pseudo-random events to a device.

  SDK也提供了monkeyrunner, 一个用python 语言编写的API测试工具, 和UI/Application Exerciser Monkey, 一个通过发送伪随机事件的做压力测试的命令行工具.

 

This document describes the fundamentals of the Android testing framework, including the structure of tests, the APIs that you use to develop tests, and the tools that you use to run tests and view results. The document assumes you have a basic knowledge of Android application programming and JUnit testing methodology.

这个文档描述了安卓测试框架的基础,包含了测试结构,提升测试的API, 你做测试和看结果的工具. 这个文档假设你有安卓程序编程和JUnit测试方法论的基础.

 

The following diagram summarizes the testing framework:

 下图总结了测试框架:

 

The Android testing framework