如何使用Jenkins/Maven进行硒测试? [英] How do I run my selenium tests with Jenkins/Maven?

查看:110
本文介绍了如何使用Jenkins/Maven进行硒测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行Ubuntu的本地计算机上设置了Jenkins,将其指向我的jdk,然后行了maven,创建了一个作业来运行我的Selenium测试,并为它提供了项目中pom.xml的路径,但是当我尝试运行作业,它立即失败.控制台输出为

I set up Jenkins on my local machine running Ubuntu, pointed it at my jdk, and maven, created a job to run my Selenium tests and gave it the path to the pom.xml in the project, but when I try to run the job, it fails right away. The console output reads

在工作区中构建/var/lib/jenkins/workspace/new job [新工作] $/usr/share/maven2/bin/mvn -f/pathto/pom.xml -Dtests = firefox_tests.xml -Dreceiver=myemail@myemail.com ...您必须至少指定一个目标或生命周期阶段执行构建步骤.以下列表说明了一些常用的构建命令: mvn clean删除所有构建输出(例如,类文件或JAR).mvn测试...

Building in workspace /var/lib/jenkins/workspace/new job [new job] $ /usr/share/maven2/bin/mvn -f /pathto/pom.xml -Dtests=firefox_tests.xml -Dreceiver=myemail@myemail.com...You must specify at least one goal or lifecycle phase to perform build steps. The following list illustrates some commonly used build commands: mvn clean Deletes any build output (e.g. class files or JARs).mvn test...

我只是不确定如何继续.如何克服这个错误并使Selenium测试与Jenkins和Maven一起运行?谢谢.

I'm just not sure how to proceed. How can I get past this error and get my Selenium tests to run with Jenkins and Maven? Thanks.

推荐答案

您是否已将硒测试与Maven生命周期挂钩?

Have you hooked the selenium test into the Maven lifecycle?

通常,硒测试将在集成测试阶段中执行,该测试可以通过以下pom.xml中的插件配置进行配置

Normally selenium tests would be executed as part of the integration-test phase, which could be configured with a plugin configuration like below in your pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <configuration>
        <skip>${skip.selenium.tests}</skip>
        <parallel>none</parallel>
        <threadCount>1</threadCount>
        <reuseForks>false</reuseForks>
        <disableXmlReport>true</disableXmlReport>
    </configuration>
    <executions>
        <execution>
            <id>runSeleniumTests</id>
            <phase>integration-test</phase>
            <goals>
                <goal>integration-test</goal>
            </goals>
        </execution>
    </executions>
</plugin>

将其添加到pom中(以及所有与Selenium的依赖关系)后,您应该可以使用

With this added to your pom (and all Selenium dependencies in place), you should be able to run the selenium tests with

mvn clean integration-test

这也是您应该在CI服务器中指定的命令. 或者,如果它只是问您要执行的目标,请选择:干净的集成测试"

And that is also the command you should specify in your CI server. Or if it just asks you for goals to execute, choose: 'clean integration-test'

这篇关于如何使用Jenkins/Maven进行硒测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆