ANT 与 CVS,SELENIUM 的集成

上一篇 / 下一篇  2007-10-10 17:51:03

7Ex%nx4L ]/f0持续集成测试的框架暂时是使用BAT批处理脚本建立每日测试的计划,然后调用ANT执行SELENIUM的JUNIT类型的自动化脚本进行测试。效果可以达到每日定时从CVSCHECK OUT出SELENIUM的脚本代码,然后清理本地执行环境->编译->执行自动化功能测试->保存日志->生成测试报告。
;q8dN+p5VKgTN0SELENIUM是开源的自动化功能测试工具,使用RC模式可以建立JUNIT脚本,例:
w Z$DP\j/YvHMa s0import ...
/D*`#M1xIlfzGC"e0public class MISTest extends TestCase
s7|Ec2~:Sl0{
4]%CX)P4h+U0private Selenium selenium;51Testing软件测试网&P}2G ^-y:[$|*M%T j7D
public void setUp() throws Exception {51Testing软件测试网/[)_T@ z
String url = "http服务器地址";51Testing软件测试网|zWI/`kI4X1t6l&]
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", http服务器地址);
.|E%X"ht7YN|.Y&s0selenium.start();51Testing软件测试网 a/hk~5N)]
}51Testing软件测试网1t `,^C6m#}
protected void tearDown() throws Exception {51Testing软件测试网4_ HM|-^^:smN
selenium.stop();51Testing软件测试网`|v&II0|d5|8\
}51Testing软件测试网hT;R$Y+as,A
public void testResLogin() throws Throwable {51Testing软件测试网*J'|,l:{9i#_p ].`D
selenium.open("地址");
b~h1].zg'jl0selenium.type("tbAccount", "admin");
`]R8C;z O!O&p0selenium.type("tbPassword", "123456");51Testing软件测试网y|!mR} S9];`
selenium.click("btnSubmit");51Testing软件测试网#A,NP.iF} M&F
selenium.waitForPageToLoad("30000");51Testing软件测试网)F}E8lCOS
selenium.selectFrame("relative=top");
y!z"`rBN%Hhu0selenium.selectFrame("TopFrame");
@_'Jpi;N0}51Testing软件测试网OG5ECq _9[,F
}51Testing软件测试网6vo)FpY|&{i
ANT的自动集成:
8`X!k,C$[6Q#M0定义属性 property name="src.code" value="SeleniumTest"
-@g)y'FwN+y+R0删除文件 delete dir="${SeleniumTest.classes}"51Testing软件测试网oi(j"VZ.C
建立文件 mkdir dir="${report.test}"51Testing软件测试网*LH J+z b_5~9r"H
显示信息 echo message="${TSTAMP}"
-H7N]&]U/u0编译JAVA文件 javac destdir="${SeleniumTest.classes}" deprecation="on"51Testing软件测试网3^9Roh S-Q0|]K7[
src path="${src.code}"
},y0U Q-wO8u'_CBJ0classpath refid="classpath"51Testing软件测试网}%u.Ev/TKa4z T
javac
O3_*C X3U@R"Yg0打包JAR jar
-_;hC xzb:V0jarfile="${SeleniumTest.classes}/SeleniumTest.jar" basedir="${SeleniumTest.classes}" include name="**/*.class" jar

P(F:DSV051Testing软件测试网FXf bP3N[

执行JUNIT51Testing软件测试网T Nn+S+Cf
junit printsummary="yes" haltonfailure="yes" classpath path refid="classpath" pathelement location="${SeleniumTest.classes}" classpath formatter type="plain" usefile="true" formatter type="xml" usefile="true" batchtest todir="${log.test}" fileset dir="${SeleniumTest.classes}" includes="**/**.class" batchtest junit

g1y"Qq O*g `*Y^4r@3^0

?d;S*zdUY0执行CVS命令51Testing软件测试网6K'e7z6nN%k3j'D6C
target name="command" depends="initpass" cvs cvsroot="${cvsroot}" command="checkout" cvsrsh="ssh" package="QC-Group" dest="D:\PROJECT\SeleniumTest\SeleniumTest" passfile="${cvs.passfile}" target51Testing软件测试网+X6T(hJ:\{

51Testing软件测试网HU*Z9pV?_ v2ATeU

执行批处理脚本51Testing软件测试网ZC[ei c'hv
exec dir="${basedir}" executable="D:\PROJECT\SeleniumTest\selenium.bat" arg value="" exec51Testing软件测试网r,oo1W/bj

51Testing软件测试网+y1?2d&qpe JD

51Testing软件测试网 F hD9A[3`VN
以上都是一些非常基本的命令。用FIRFOX浏览器可能有点问题,呵呵51Testing软件测试网.|]d Cvw8P [.s/u5j

;gQe0I7N4S0

TAG:

wu清敏的个人空间 引用 删除 wu清敏   /   2014-12-24 15:03:48
3
引用 删除 wlh206   /   2010-09-14 14:28:22
3
 

评分:0

我来说两句

日历

« 2023-12-27  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 31211
  • 日志数: 33
  • 图片数: 3
  • 文件数: 8
  • 建立时间: 2007-10-10
  • 更新时间: 2011-06-28

RSS订阅

Open Toolbar