jenkins是流行的集成测试工具,在上面建立编译,发布,运行单体测试的任务都非常方便。
selenium是优秀的Web画面的自动化结合测试工具,它的测试代码有两种形式。
一种是用java,C#等高级语言编写的,特点是功能强大。
另一种是用HTML写的,特点是使用方便。
下面以HTML形式的test suite为例,说明如何在jenkins中配置selenium测试。
先下载插件,在jenkins的plugin管理画面中,选择安装Hudson Seleniumhq plugin。
安装完后重启jenkins。
然后下载selenium-server。其实就是一个jar文件。例如,selenium-server-standalone-2.21.0.jar
用这个jar文件,就可以实现命令行运行selenium测试。
命令行格式如下,
java -jar D:/workspace/testproject/selenium/selenium-server-standalone-2.21.0.jar -htmlSuite "*iexplore" "http://localhost:8081" "D:/workspace/testproject/selenium/alltests.html" "D:/workspace/testproject/selenium/results.html" -port 4445
先用命令行测试一下,看看能否生成测试结果(上例中,results.html)
准备工作就绪,接下来把它配置到Jenkins的具体的Job中。
新建或利用既存的Job,在Job设定中,追加build步骤,