Android Studio+Appium+TestNG数据驱动框架搭建
2016-11-02 15:28
417 查看
Eclipse+Appium+TestNG项目迁移到Android Studio
在Android Studio中建立Project后,新建同名的Module,这里Eclipse的Project名是appiumcombat,因此,Android Studio中Module名称也为appiumcombat。(Android Studio和Eclipse目录结构差异请自行了解)。
将Eclipse下的文件逐一复制到Android Studio的Module下方,复制过程中对应关系需要修改的检查一下。复制好之后目录结构如下:
将Eclipse中的pom.xml中的配置内容转换到build.gradle文件中。
方法:
下载gradle 2.0并安装,配置环境变量(类似JDK环境变量的配置)
然后在maven根目录下运行
gradle init --type pom
打开生成的build.gradle文件,查看里面的dependencies内容,已经转换成Android
Studio可用的依赖配置。可以直接复制需要的部分到Android Studio中的build.gradle文件中。
以下是转换后整理修改好的build.gradle代码:(sync之后就会自动下载依赖的jar包)
修改File--setting中的默认编码为UTF-8,Apply后重启Android Studio,并且在gradle配置文件中添加如下内容。亲测有效:
参考:https://www.douban.com/note/507175402/
1,文件迁移
Eclipse中完整的Maven Project数据驱动框架结构:在Android Studio中建立Project后,新建同名的Module,这里Eclipse的Project名是appiumcombat,因此,Android Studio中Module名称也为appiumcombat。(Android Studio和Eclipse目录结构差异请自行了解)。
将Eclipse下的文件逐一复制到Android Studio的Module下方,复制过程中对应关系需要修改的检查一下。复制好之后目录结构如下:
2, maven -->gradle(pom.xml文件转换成build.gradle文件)
参考:http://www.cnblogs.com/softidea/p/5631341.html将Eclipse中的pom.xml中的配置内容转换到build.gradle文件中。
方法:
下载gradle 2.0并安装,配置环境变量(类似JDK环境变量的配置)
然后在maven根目录下运行
gradle init --type pom
打开生成的build.gradle文件,查看里面的dependencies内容,已经转换成Android
Studio可用的依赖配置。可以直接复制需要的部分到Android Studio中的build.gradle文件中。
以下是转换后整理修改好的build.gradle代码:(sync之后就会自动下载依赖的jar包)
apply plugin: 'java' apply plugin: 'eclipse' version = '1.0' jar { manifest { attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version } } tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } test { useTestNG() } repositories { mavenCentral() } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile group: 'commons-configuration', name: 'commons-configuration', version:'1.9' compile(group: 'io.appium', name: 'java-client', version:'3.4.1') { exclude(module: 'selenium-java') } compile group: 'com.google.code.gson', name: 'gson', version:'2.2.4' compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version:'2.53.0' compile group: 'org.apache.poi', name: 'poi-ooxml', version:'3.10-FINAL' compile group: 'org.seleniumhq.selenium', name: 'selenium-remote-driver', version:'2.53.0' compile group: 'com.thoughtworks.qdox', name: 'qdox', version:'1.12.1' testCompile group: 'org.testng', name: 'testng', version:'6.9.6' testCompile group: 'com.googlecode.json-simple', name: 'json-simple', version:'1.1' testCompile group: 'commons-lang', name: 'commons-lang', version:'2.6' testCompile group: 'com.saucelabs', name: 'sauce_junit', version:'2.1.21' compile(group: 'net.sourceforge.jexcelapi', name: 'jxl', version:'2.6.12') { /* This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. */ } compile(group: 'log4j', name: 'log4j', version:'1.2.16') { /* This dependency was originally in the Maven provided scope, but the project was not of type war. This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. Please review and delete this closure when resolved. */ } }
3,运行testng测试
这时,可能会报很多Gradle: 错误: 编码GBK的不可映射字符
解决方法:修改File--setting中的默认编码为UTF-8,Apply后重启Android Studio,并且在gradle配置文件中添加如下内容。亲测有效:
参考:https://www.douban.com/note/507175402/
4,数据驱动问题
本来这个用例是通过读取data文件夹里的excel文件数据来传递测试参数,但是运行一直提示Test ignored,找不到原因,后来删除dataProvider相关的代码后,运行,即可测试通过。数据驱动的问题仍在摸索中。
相关文章推荐
- android框架搭建——封装一个属于自己的数据存储工具类(SQLite篇)
- 关键字驱动框架入门教程-4-搭建数据引擎-用Apache POI去读取数据
- [Android测试] Android Studio+Appium+Java+Windows 自动化测试之二:Appium环境安装搭建
- 3.Appium+AndroidStudio环境搭建
- 基于testNg的测试框架设计(一)数据驱动
- eclipse+adt+android sdk搭建框架appium
- [Android测试] AS+Appium+Java+Win 自动化测试之四: 单元测试框架和TestNg
- 基于testNG框架的分层式数据驱动自动化测试设计与研发(一)
- Android环境搭建Appium测试框架 Python
- Ubuntu 10.04环境搭建android驱动开发环境
- Android游戏开发:游戏框架的搭建(2)
- [Android游戏开发]游戏框架的搭建
- 用.Net打造一个移动客户端(Android/IOS)的服务端框架NHM(二)——“请求”“交互”与传输数据(服务器端)
- Android游戏开发:游戏框架的搭建(1)
- Android游戏开发:游戏框架的搭建(4)
- Android游戏开发:游戏框架的搭建(4)
- android jni 程序框架搭建
- 采用CakePHP框架为Android应用快速搭建Web Service服务器及API接口的PHP代码实例
- Android_ics_stagefright框架数据流向分析——1,待解码的原始数据从何而来
- Android 游戏开发----【搭建游戏开发框架】