如何在Android Studio中使用Robotium? [英] How to use Robotium with Android Studio?

查看:348
本文介绍了如何在Android Studio中使用Robotium?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Robotium 是一个Android测试自动化框架,完全支持本机和混合应用程序.

Robotium is an Android test automation framework that has full support for native and hybrid applications.

现在,Android Studio是用于Android开发的事实 IDE,我很想在Android Studio上尝试一下.但是,我找不到设置它的方法.

Now that Android Studio is the de facto IDE for Android development, I'm interested to try this with Android Studio. However, I couldn't find a way to set it up.

如何设置和使用Robotium进行Android Studio测试?

How to setup and use Robotium to test with Android Studio?

推荐答案

指南:

  1. 将以下行添加到内部build.gradle文件的 dependencies 部分(此文件与 src 文件夹位于同一级别),更改版本名称(如果需要):

  1. Add the following line to the dependencies section of the inner build.gradle file (this file is located at the same level as src folder), change version name if required:

androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.2.1'

如果由于某种原因您不想让gradle为您下载依赖项,那么 您可以手动添加它们:将robotium.jar放入 libs 文件夹中.右键单击它,然后选择添加为库...

If for some reason you don't want to let gradle download dependencies for you then you can add them manually: Place robotium.jar into the libs folder. Right click it and select Add as library...

src 文件夹中创建另一个文件夹 androidTest

In the src folder create another folder androidTest

选择创建测试.为Robotium选择适当的超类:

Select Create Test. Select the proper superclass for Robotium:

android.test.ActivityInstrumentationTestCase2

  • Android Studio将创建一个测试文件和一个程序包(如果不是在步骤6中创建的话)
  • 如何运行测试:

  • Android studio will create a test file and a package (if it wasn’t created in step 6)
  • How to run the test:

    • UI:照常使用Android Studio 运行菜单
    • 控制台:在终端中输入以下命令:

    • UI: as usual using Android Studio Run menu
    • console: in the terminal enter the following command:

    ./gradlew connectedAndroidTest
    

    HTML报告将在"YourApp/YourApp/build/outputs/reports/androidTests/ connected/index.html"

    The HTML-reports will be generated at "YourApp/YourApp/build/outputs/reports/androidTests/ connected/index.html"

    这篇关于如何在Android Studio中使用Robotium?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆