首页 文章 精选 留言 我的

精选列表

搜索[test],共10005篇文章
优秀的个人博客,低调大师

Spark Test

练习关于讲list分为奇 偶 并求出占比 练习 关于需求 表合并 reduce filter 等操作 Spark 中 RDD 过程 transformation 和 Action 大多数操作基于transformation 所以 可以链式写法 package com.zhiyou100 import org.apache.spark.{SparkConf, SparkContext} object HomeWork { val conf =new SparkConf().setMaster("local[*]").setAppName("home work") val sc= SparkContext.getOrCreate(conf) //作业一 def ListsortTest()={ val list =List(1,2,43,5,6,7,76,8,9,0,3) val rdd=sc.parallelize(list) val allnum =rdd.count() val qiAccmulator=sc.longAccumulator("qishu") val ouAccmulator=sc.longAccumulator("oushu") rdd.foreach(x=>{if (x%2==0) qiAccmulator.add(1) else ouAccmulator.add(1) }) val qibi=(qiAccmulator.value/allnum.toDouble) val oubi =(ouAccmulator.value/allnum.toDouble) println(s"总数:$allnum:奇数:$qiAccmulator 占比:$qibi:偶数:$ouAccmulator:占比:$oubi") } //作业二 def getorderResult()={ val rdd =sc.textFile("/orderdata/customers/") val userId = rdd.map(x=>{ val infos =x.split("\\|") (infos(0).toInt,s"${infos(1)}.${infos(2)}") }) userId.foreach(println) val rdd1 =sc.textFile("/orderdata/orders") val orderId =rdd1.map(x=>{ val infos1=x.split("\\|") (infos1(2).toInt, infos1(0)) // (infos1(1), infos1(0)) }) val orderId2=rdd1.filter(x=>{ x.split("\\|")(3).equals("COMPLETE") })map(x=>{ val infos11=x.split("\\|") (infos11(0),infos11(2)) }) val getJoin=orderId.join(userId).map(x=>(x._1,1)).reduceByKey(_+_).join(userId) orderId.foreach(println) val kuanbiao=orderId.join(userId) //userId(订单数,username) getJoin.foreach(println) val rdd2=sc.textFile("/orderdata/products/") val productId =rdd2.map(x=>{ val infos2=x.split("\\|") (infos2(0).toInt,(infos2(2),infos2(4))) }) // productId.foreach(println) // getJoin.foreach(println) kuanbiao.foreach(println) //(productId ,(userId ,username)) val kuanbiao1=kuanbiao.map(x=>{ (x._2._1.toInt,(x._1,x._2._2)) }).join(productId).map(x=>{ (x._2._1._1.toInt,x._2._2._2.toDouble) }).reduceByKey(_+_).join(userId) // //计算出个人消费总金额 // kuanbiao.foreach(println) val kuanbiao2=kuanbiao.map(x=>{ (x._2._1.toInt,(x._1,x._2._2)) }).join(productId).map(x=>{ (x._2._1._1,x._2._2._1) }).countByKey() //计算user的购买产品个数 kuanbiao2.foreach(println) } def thirdHome()={ val rdd =sc.textFile("/orderdata/categories/") val categories=rdd.map(x=>{ val infos = x.split("\\|") (infos(1).toInt,(infos(0),(infos(2)))) }) val rdd1=sc.textFile("/orderdata/departments") val department=rdd1.map(x=>{ val infos1 = x.split("\\|") (infos1(0).toInt,infos1(1)) }) val rdd2 =sc.textFile("/orderdata/products/") val productId =rdd2.map(x=>{ val infos2=x.split("\\|") (infos2(1).toInt,(infos2(2),infos2(4))) }) val q1 =department.join(categories).map(x=>(x._1,x._2._2._1.toInt)).reduceByKey(_+_) val q2 =department.join(categories).map(x=>(x._1,x._2._2._1)).countByKey() val q3 =department.join(categories).map(x=>()) //商品数量 q1.foreach(println) q2.foreach(println) q3.foreach(println) } def main(args: Array[String]): Unit = { // ListsortTest() // getorderResult() thirdHome() } }

优秀的个人博客,低调大师

Android Monkeyrunner Test

关于 Android 自动化测试,研究了Monkey,Robotium 这次来看下 Monkeyrunner. 具体实践最靠谱的当然还是官网资料了。 http://developer.android.com/tools/help/monkeyrunner_concepts.html 这里简单记录下实践过程,Monkeyrunner 需要用 Python来编写,对于曾未学过Python的童鞋来说也没关系,因为Python属于比较好学的一门脚本语言.笔者也未曾学过Python,但有其他编程基础如:PHP,Java,Peal,还是能够很好理解Python的。 一、monkeyrunner 介绍 monkeyrunner 提供了一个API,使用此API写出的程序可以在Android代码之外控制Android设备和模拟器. 二、monkeyrunner 测试类型 多设备控制、 功能测试、回归测试 三、实例(测试MyAndroid.apk) 1. 新建一个 monkeyrunnerTest.py # Import the monkey runner modules used by this program from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage # Connects to current device, returning a MonkeyDevice object device = MonkeyRunner.waitForConnection() # Installs the Android package device.installPackage("./MyAndroid.apk") # Runs the component device.startActivity(component = 'com.luwenjie.android/.MyAndroidActivity') #Presses the Menu button device.press('KEYCODE_MENU','DOWN_AND_UP') #Takes a screenshot result = device.takeSnapshot() # Writes the screenshot to a file result.writeToFile('./shot1.png','png') 2. 运行在 %Android_HOME%\tools 目录下运行一下命令 monkeyrunner monkeyrunnerTest.py 四、API参考 MonkeyRunner:http://developer.android.com/tools/help/MonkeyRunner.html MonkeyDevice:http://developer.android.com/tools/help/MonkeyDevice.html MonkeyImage:http://developer.android.com/tools/help/MonkeyImage.html 五、录制模式 #Usage: monkeyrunner recorder.py #recorder.py http://mirror.yongbok.net/linux/android/repository/platform/sdk/monkeyrunner/scripts/monkey_recorder.py from com.android.monkeyrunner import MonkeyRunner as mr from com.android.monkeyrunner.recorder import MonkeyRecorder as recorder device = mr.waitForConnection() recorder.start(device) #END recorder.py #Press ExportAction to save recorded scrip to a file #Example of result: #PRESS|{'name':'MENU','type':'downAndUp',} #TOUCH|{'x':190,'y':195,'type':'downAndUp',} #TYPE|{'message':'',} #Usage: monkeyrunner playback.py "myscript" #playback.py http://mirror.yongbok.net/linux/android/repository/platform/sdk/monkeyrunner/scripts/monkey_playback.py import sys from com.android.monkeyrunner import MonkeyRunner # The format of the file we are parsing is very carfeully constructed. # Each line corresponds to a single command. The line is split into 2 # parts with a | character. Text to the left of the pipe denotes # which command to run. The text to the right of the pipe is a python # dictionary (it can be evaled into existence) that specifies the # arguments for the command. In most cases, this directly maps to the # keyword argument dictionary that could be passed to the underlying # command. # Lookup table to map command strings to functions that implement that # command. CMD_MAP = { 'TOUCH': lambda dev, arg: dev.touch(**arg), 'DRAG': lambda dev, arg: dev.drag(**arg), 'PRESS': lambda dev, arg: dev.press(**arg), 'TYPE': lambda dev, arg: dev.type(**arg), 'WAIT': lambda dev, arg: MonkeyRunner.sleep(**arg) } # Process a single file for the specified device. def process_file(fp, device): for line in fp: (cmd, rest) = line.split('|') try: # Parse the pydict rest = eval(rest) except: print 'unable to parse options' continue if cmd not in CMD_MAP: print 'unknown command: ' + cmd continue CMD_MAP[cmd](device, rest) def main(): file = sys.argv[1] fp = open(file, 'r') device = MonkeyRunner.waitForConnection() process_file(fp, device) fp.close(); if __name__ == '__main__': main() 最新内容请见作者的GitHub页:http://qaseven.github.io/

优秀的个人博客,低调大师

Appium环境抢建(for web browser test)

Android SDK Appium 安装 nodejs 安装 Appium 配置手机 下载&运行测试项目 Appium是Android平台上一个测试框架。 本文简单地介绍如何在Linux机器上安装并运行该框架。 应用环境: Ubuntu 12.04 LTS HTC One X (endeavoru, S720e) Android SDK 请参考SDK环境,这里就不多说了。 Appium 安装 nodejs apt-get install nodejs # 或者通过nodejs源码编译,这样可以使用最新的代码 cd ~/downloads wget http://nodejs.org/dist/v0.10.25/node-v0.10.25.tar.gz tar -zxf node-v0.10.25.tar.gz cd ode-v0.10.25 ./configure --prefix=/usr/local/node make && make install # edit ~/.bashrc and add node to your PATH env 安装 Appium npm install -g appium # install appium as a global app 配置手机 手机需要是已经root过的! adb shell su chmod 777 /data/local 另外,也要确保你手机上安装了最新的chrome浏览器! Note: 这步是必需的,否则后面会发生无法启动浏览器的异常。 下载&运行测试项目 # 下载项目 git clone git@github.com:ytfei/appium_chrome_demo.git cd appium_chrome_demo npm install # 安装依赖包 # 启动appium appium -g appium.log & # 开始测试 node web.js 最新内容请见作者的GitHub页:http://qaseven.github.io/

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册