forked from if1else0/newstest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit whole uiautomator test project
- Loading branch information
0 parents
commit eaf8387
Showing
56 changed files
with
1,002 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/> | ||
<classpathentry kind="lib" path="/Users/aaronyang/Library/Android/sdk/platforms/android-19/android.jar"/> | ||
<classpathentry kind="lib" path="/Users/aaronyang/Library/Android/sdk/platforms/android-19/uiautomator.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>news</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes.dex : \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/BasicTestCase.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/pages/PageCommon.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/pages/PageLogin.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/pages/PageMy.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/pages/PageMyFavorites.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/pages/PageNavigation.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/pages/PageNews.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/pages/PageNewsDetail.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/pages/PageQQLoginType.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/pages/PageQQRegister.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/pages/PageSettings.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/PagesManager.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/testcases/TestCase1.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/testcases/TestCase2.class \ | ||
/Users/aaronyang/Documents/workspace/news/bin/classes/com/news/test/UiObjectHelper.class \ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project name="news" default="help"> | ||
|
||
<!-- The local.properties file is created and updated by the 'android' tool. | ||
It contains the path to the SDK. It should *NOT* be checked into | ||
Version Control Systems. --> | ||
<property file="local.properties" /> | ||
|
||
<!-- The ant.properties file can be created by you. It is only edited by the | ||
'android' tool to add properties to it. | ||
This is the place to change some Ant specific build properties. | ||
Here are some properties you may want to change/update: | ||
source.dir | ||
The name of the source directory. Default is 'src'. | ||
out.dir | ||
The name of the output directory. Default is 'bin'. | ||
For other overridable properties, look at the beginning of the rules | ||
files in the SDK, at tools/ant/build.xml | ||
Properties related to the SDK location or the project target should | ||
be updated using the 'android' tool with the 'update' action. | ||
This file is an integral part of the build system for your | ||
application and should be checked into Version Control Systems. | ||
--> | ||
<property file="ant.properties" /> | ||
|
||
<!-- if sdk.dir was not set from one of the property file, then | ||
get it from the ANDROID_HOME env var. | ||
This must be done before we load project.properties since | ||
the proguard config can use sdk.dir --> | ||
<property environment="env" /> | ||
<condition property="sdk.dir" value="${env.ANDROID_HOME}"> | ||
<isset property="env.ANDROID_HOME" /> | ||
</condition> | ||
|
||
<!-- The project.properties file is created and updated by the 'android' | ||
tool, as well as ADT. | ||
This contains project specific properties such as project target, and library | ||
dependencies. Lower level build properties are stored in ant.properties | ||
(or in .classpath for Eclipse projects). | ||
This file is an integral part of the build system for your | ||
application and should be checked into Version Control Systems. --> | ||
<loadproperties srcFile="project.properties" /> | ||
|
||
<!-- quick check on sdk.dir --> | ||
<fail | ||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable." | ||
unless="sdk.dir" | ||
/> | ||
|
||
<!-- | ||
Import per project custom build rules if present at the root of the project. | ||
This is the place to put custom intermediary targets such as: | ||
-pre-build | ||
-pre-compile | ||
-post-compile (This is typically used for code obfuscation. | ||
Compiled code location: ${out.classes.absolute.dir} | ||
If this is not done in place, override ${out.dex.input.absolute.dir}) | ||
-post-package | ||
-post-build | ||
-pre-clean | ||
--> | ||
<import file="custom_rules.xml" optional="true" /> | ||
|
||
<!-- Import the actual build file. | ||
To customize existing targets, there are two options: | ||
- Customize only one target: | ||
- copy/paste the target into this file, *before* the | ||
<import> task. | ||
- customize it to your needs. | ||
- Customize the whole content of build.xml | ||
- copy/paste the content of the rules files (minus the top node) | ||
into this file, replacing the <import> task. | ||
- customize to your needs. | ||
*********************** | ||
****** IMPORTANT ****** | ||
*********************** | ||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer, | ||
in order to avoid having your file be overridden by tools such as "android update project" | ||
--> | ||
<!-- version-tag: VERSION_TAG --> | ||
<import file="${sdk.dir}/tools/ant/uibuild.xml" /> | ||
|
||
</project> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file is automatically generated by Android Tools. | ||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
# | ||
# This file must be checked in Version Control Systems. | ||
# | ||
# To customize properties used by the Ant build system edit | ||
# "ant.properties", and override values to adapt the script to your | ||
# project structure. | ||
# | ||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): | ||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt | ||
|
||
# Project target. | ||
target=android-19 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import os | ||
import fileinput | ||
#删除存在的log文件或者报告文件,避免以前构建产生的数据对当前构建造成影响 | ||
if os.path.exists("log.txt"): | ||
os.remove("log.txt") | ||
if os.path.exists("log.xml"): | ||
os.remove("log.xml") | ||
|
||
#编译生成jar | ||
os.system("ant build") | ||
|
||
#push jar到设备 | ||
os.system("adb push bin/newtest.jar /data/local/tmp/") | ||
|
||
#遍历读取testsuites.txt文件里的每一行信息 | ||
for line in fileinput.input("testsuites.txt"): | ||
#如果这一行的文本不为空 | ||
if len(line.strip()) != 0 : | ||
#拼接执行的遇见,并把log输出到外部文件log.txt | ||
exeStr = "adb shell uiautomator runtest newtest.jar -c " + line.strip() + " >>log.txt" | ||
#执行拼接完的语句 | ||
os.system(exeStr) | ||
|
||
#转化log文件为JUnit报告 | ||
os.system("java -jar log-converter.jar log.txt") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.news.test; | ||
|
||
import com.android.uiautomator.testrunner.UiAutomatorTestCase; | ||
|
||
public class BasicTestCase extends UiAutomatorTestCase{ | ||
protected PagesManager pm = null; | ||
/** | ||
* 通过aapt dump badging apkname获得这两个信息 | ||
*/ | ||
String packageName = "com.netease.newsreader.activity"; | ||
String activityName = "com.netease.nr.biz.ad.AdActivity"; | ||
|
||
|
||
protected void setUp(boolean isNeedLogin) throws Exception { | ||
// TODO Auto-generated method stub | ||
super.setUp(); | ||
/** | ||
* 通过am start命令启动被测试应用,这样可以确保在不同的手机或者OS上用统一的代码启动测试应用 | ||
*/ | ||
Runtime.getRuntime().exec( | ||
"am start -n " + packageName + "/" + activityName); | ||
pm = new PagesManager(); | ||
Thread.sleep(1000); | ||
if(isNeedLogin){ | ||
pm.getPageNavigation().goToMySettingsTab(); | ||
pm.getPageMy().clickLoginImageView(); | ||
pm.getPageLogin().login("robotium2016@163.com", "uiautomator"); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package com.news.test; | ||
|
||
import com.news.test.pages.PageCommon; | ||
import com.news.test.pages.PageLogin; | ||
import com.news.test.pages.PageMy; | ||
import com.news.test.pages.PageMyFavorites; | ||
import com.news.test.pages.PageNavigation; | ||
import com.news.test.pages.PageNews; | ||
import com.news.test.pages.PageNewsDetail; | ||
import com.news.test.pages.PageQQLoginType; | ||
import com.news.test.pages.PageQQRegister; | ||
import com.news.test.pages.PageSettings; | ||
|
||
public class PagesManager { | ||
PageNavigation pageNavigation; | ||
PageLogin pageLogin; | ||
PageNews pageNews; | ||
PageNewsDetail pageNewsDetail; | ||
PageMy pageMy; | ||
PageMyFavorites pageMyFavorites; | ||
PageSettings pageSettings; | ||
PageCommon pageCommon; | ||
PageQQLoginType pageQQLoginType; | ||
PageQQRegister pageQQRegister; | ||
|
||
public PageNavigation getPageNavigation(){ | ||
if(pageNavigation == null){ | ||
pageNavigation = new PageNavigation(); | ||
} | ||
return pageNavigation; | ||
} | ||
|
||
public PageLogin getPageLogin(){ | ||
if(pageLogin == null){ | ||
pageLogin = new PageLogin(); | ||
} | ||
return pageLogin; | ||
} | ||
|
||
public PageNews getPageNews(){ | ||
if(pageNews == null){ | ||
pageNews = new PageNews(); | ||
} | ||
return pageNews; | ||
} | ||
|
||
public PageNewsDetail getPageNewsDetail(){ | ||
if(pageNewsDetail == null){ | ||
pageNewsDetail = new PageNewsDetail(); | ||
} | ||
return pageNewsDetail; | ||
} | ||
|
||
public PageMy getPageMy(){ | ||
if(pageMy == null){ | ||
pageMy = new PageMy(); | ||
} | ||
return pageMy; | ||
} | ||
|
||
public PageMyFavorites getPageMyFavorites(){ | ||
if(pageMyFavorites == null){ | ||
pageMyFavorites = new PageMyFavorites(); | ||
} | ||
return pageMyFavorites; | ||
} | ||
|
||
public PageSettings getPageSettings(){ | ||
if(pageSettings == null){ | ||
pageSettings = new PageSettings(); | ||
} | ||
return pageSettings; | ||
} | ||
|
||
public PageCommon getPageCommon(){ | ||
if(pageCommon == null){ | ||
pageCommon = new PageCommon(); | ||
} | ||
return pageCommon; | ||
} | ||
|
||
public PageQQLoginType getPageQQLoginType(){ | ||
if(pageQQLoginType == null){ | ||
pageQQLoginType = new PageQQLoginType(); | ||
} | ||
return pageQQLoginType; | ||
} | ||
|
||
public PageQQRegister getPageQQRegister(){ | ||
if(pageQQRegister == null){ | ||
pageQQRegister = new PageQQRegister(); | ||
} | ||
return pageQQRegister; | ||
} | ||
|
||
} |
Oops, something went wrong.