selenium是一个非常棒的测试web应用的工具。特别是使用Selenium Remote Control (RC)
,你可以在多种操作系统下用多种浏览器测试你的web应用,并且可以使用多种语言编写testcase,当然包括Java。
参考: http://seleniumhq.org/
下文讨论了如何在maven2的环境下实现一键式的集成测试,进而可以使用持续集成工具完成自动化的持续集成。
测试环境:
ubuntu 8.10
JDK6
maven2
tomcat6
maven2的默认生命周期中的阶段中在package之后有:
pre-integration-test |
执行一些在集成测试运行之前需要的动作。如建立集成测试需要的环境 |
integration-test |
如果有必要的话,处理包并发布至集成测试可以运行的环境 |
post-integration-test |
执行一些在集成测试运行之后需要的动作。如清理集成测试环境。 |
那么要做的事情就很清楚了,
第一步:在pre-integration-test阶段,把package阶段打好的war包redeploy到tomcat。
把Selenium Remote Control(RC)启动起来
第二步:在integration-test阶段,运行selenium的test cases
第三步:在post-integration-test阶段,把Selenium Remote Control(RC)停止
我的pom.xml代码片段:
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin
</artifactId>
<configuration>
<url>http://www.test.com:8080/manager</url>
<server>test</server>
<path>/</path>
</configuration>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>undeploy</goal>
<goal>deploy-only</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin
</artifactId>
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<background>true</background>
</configuration>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-server</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin
</artifactId>
<configuration>
<includes>
<include>com/demo/action/**/*Test.java</include>
</includes>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>selenium/*Test.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
tomcat-maven-plugin的配置请参考 http://blog.csdn.net/dqatsh/archive/2009/02/18/3905274.aspx
这里在配置文件中使用了execution把plugin的某个goal绑定到生命周期的某个阶段。
但对于maven-surefire-plugin这个plugin来说,它缺省就被绑定到test这个阶段了。由于其中的test cases既有单元测试的,又有selenium集成测试的,所以用include来过滤区分一下,保证不同的阶段运行所需要运行的测试。
分享到:
相关推荐
博客https://blog.csdn.net/weixin_49457347/article/details/1236所需文件
https://download.csdn.net/download/p_xiaojia/9756173
(注:該專欄中又引用《Jo Muncher's Blog》http://blog.csdn.net/JoMuncher/archive/2007/11/02/1862977.aspx) 看到DataGridView 多维合并标题,感覺很好,而且自己正在學寫控件(面向對象的概念還很模糊),所以好好...
http://blog.csdn.net/qq282133/article/details/7616809
KITTI数据集可视化教程,教程:https://blog.csdn.net/cg129054036/article/details/119516704
part1 http://download.csdn.net/source/1796398 part2 http://download.csdn.net/source/1796504 part3 http://download.csdn.net/source/1796920 part4 http://download.csdn.net/source/1796566 part5 ...
官方地址:http://mhdd.com/,其他下载地址:https://hddguru.com/software/2006.02.10-Magic-Boot-Disk/,使用方法请参考我的博文:https://blog.csdn.net/sdnuwjw/article/details/90143711
DataList分页1:http://blog.csdn.net/zhyuanshan/archive/2007/10/30/1855507.aspx DataList分页2: http://blog.csdn.net/zhyuanshan/archive/2008/01/10/2033688.aspx
主要讲述以http://blog.csdn.net/LCL_data/archive/2009/12/09/4974499.aspx中的链表逆序为模板来讲述指针的使用
支持局域网、广域网操作,不用专门跑到机房去关闭电脑,很方便。程序代码:http://blog.csdn.net/linjimu/archive/2008/10/11/3057448.aspx
这是本人过去收集网上的清晰扫描图片,和预览样章合并制成的pdf。由于当时是自已学习用,所以边看边制目录书签。现在放上来希望能攒点分。由于文件有127M大,所以...第六分卷:http://download.csdn.net/source/3000440
Socket实战——UDP连接:https://blog.csdn.net/haoranhaoshi/article/details/86601468 Socket实战——TCP连接:https://blog.csdn.net/haoranhaoshi/article/details/86601522 Socket实战——查询数据库:...
BP神经网络预测代码,可以直接运行。BP神经网络博客和代码参考地址:https://blog.csdn.net/qq_57971471/article/details/121766454
程序员表白程序,开放源码,不断更新(第三篇:第二弹),这是loveyue系列的源码,详情请参照博客:http://blog.csdn.net/wuxia2001/article/details/45743641
QT的Oracle驱动插件QOCI-for Win32 用法说明请参考: http://blog.csdn.net/fm0517/archive/2010/05/21/5613289.aspx
滑动刻度尺。详情 有图有真相 http://blog.csdn.net/liudao7994/article/details/45966913
http://blog.csdn.net/u012305710/article/details/52059901
更详细的信息请参见http://topic.csdn.net/t/20060328/11/4644901.html。 这7种FFT代码包括。 1. galois_godel()给出的程序 2. http://topic.csdn.net/t/20060222/13/4570436.html中的程序 3. 朱志刚的FFT程序...
https://gamwatcher.blog.csdn.net/article/details/123851513
自定义View实现空调遥控器切换度数http://blog.csdn.net/u012305710/article/details/51859542