简体   繁体   English

如何使用Jenkins / Maven进行硒测试?

[英]How do I run my selenium tests with Jenkins/Maven?

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. 我在运行Ubuntu的本地计算机上设置Jenkins,将其指向我的jdk,然后进行maven,创建了一个作业来运行我的Selenium测试,并为它提供了项目中pom.xml的路径,但是当我尝试运行该作业时,它立即失败。 The console output reads 控制台输出显示

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. 在工作区中构建/ 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 ...您必须至少指定一个目标或生命周期阶段才能执行构建步骤。 The following list illustrates some commonly used build commands: mvn clean Deletes any build output (eg class files or JARs).mvn test... 以下列表说明了一些常用的构建命令:mvn clean删除任何构建输出(例如,类文件或JAR)。mvn test ...

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? 如何克服这个错误并使Selenium测试与Jenkins和Maven一起运行? Thanks. 谢谢。

Have you hooked the selenium test into the Maven lifecycle? 您是否已将硒测试与Maven生命周期挂钩?

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 通常,硒测试将在集成测试阶段中执行,该测试可以通过以下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>

With this added to your pom (and all Selenium dependencies in place), you should be able to run the selenium tests with 将此添加到pom(以及所有Selenium依赖项)后,您应该能够使用以下命令运行selenium测试:

mvn clean integration-test

And that is also the command you should specify in your CI server. 这也是您应该在CI服务器中指定的命令。 Or if it just asks you for goals to execute, choose: 'clean integration-test' 或者,如果它只是问您要执行的目标,请选择:“干净的集成测试”

According to your error and output, you are running it as: 根据您的错误和输出,您将其运行为:

mvn -f /pathto/pom.xml -Dtests=firefox_tests.xml -Dreceiver=myemail@myemail.com

So, there is no any goal what to build here. 因此,在此构建任何目标没有任何目标。 How are you running it manually? 您如何手动运行它? Probably forgotten to run as "mvn test -f ..." ? 可能忘记了以“ mvn test -f ...”的身份运行?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM