Android翻译_测试最佳实践_测试你的Activity_建立测试环境

本章翻译说明:以为时间精力有限,在这部分完全按照Android 文档翻译,并对容易理解的直接复制,做一定的注释说明,需要翻译做到英汉对照。

本章源地址:http://developer.android.com/training/activity-testing/preparing-activity-testing.html

Setting Up Your Test Environment

Before you start writing and running your tests, you should set up your test development environment. This lesson teaches you how to set up the Eclipse IDE to build and run tests, and how to build and run tests with the Gradle framework by using the command line interface.

Note: To help you get started, the lessons are based on Eclipse with the ADT plugin. However, for your own test development, you are free to use the IDE of your choice or the command-line.

//在你测试之前需要进行建立环境,可以通过两种方式建立

Set Up Eclipse for Testing


Eclipse with the Android Developer Tools (ADT) plugin provides an integrated development environment for you to create, build, and run Android application test cases from a graphical user interface (GUI). A convenient feature that Eclipse provides is the ability to auto-generate a new test project that corresponds with your Android application project.

To set up your test environment in Eclipse:

  1. Download and install the Eclipse ADT plugin, if you haven’t installed it yet.
  2. Import or create the Android application project that you want to test against.
  3. Generate a test project that corresponds to the application project under test. To generate a test project for the app project that you imported:

     

    1. In the Package Explorer, right-click on your app project, then select Android Tools > New Test Project.
    2. In the New Android Test Project wizard, set the property values for your test project then click Finish.

You should now be able to create, build, and run test cases from your Eclipse environment. To learn how to perform these tasks in Eclipse, proceed to Creating and Running a Test Case.

//在Eclipse里面建立一个测试工程即可,最新的ADT是 右键->new->other->搜索Android Test project->选择需要被测试的目标工程->Finish.

Set Up the Command Line Interface for Testing


If you are using Gradle version 1.6 or higher as your build environment, you can build and run your Android application tests from the command line by using the Gradle Wrapper. Make sure that in your gradle.buildfile, the minSdkVersion attribute in the defaultConfig section is set to 8 or higher. You can refer to the samplegradle.build file that is included in the download bundle for this training class.

To run your tests with the Gradle Wrapper:

  1. Connect a physical Android device to your machine or launch the Android Emulator.
  2. Run the following command from your project directory:
    ./gradlew build connectedCheck

To learn more about using Gradle for Android testing, see the Gradle Plugin User Guide.

To learn more about using command line tools other than Gradle for test development, see Testing from Other IDEs.

转载于:https://www.cnblogs.com/RainFool/p/4755128.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值