Maven 货物和硒

发布于 2024-10-15 20:57:38 字数 4056 浏览 3 评论 0原文

我使用 Maven Cargo 和 Selenium 来实现自动化。这是代码:

<plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.0.5</version>
            <configuration>
                <wait>false</wait>
                <container>
                    <containerId>tomcat6x</containerId>
                    <zipUrlInstaller>
                        <url>
                            http://mirrors.enquira.co.uk/apache/tomcat/tomcat-6/v6.0.30/bin/apache-tomcat-6.0.30.zip
                        </url>
                        <installDir>${installDir}</installDir>
                    </zipUrlInstaller>
                    <output>
                        ${project.build.directory}/tomcat6x.log
                    </output>
                    <log>${project.build.directory}/cargo.log</log>
                </container>
                <configuration>
                    <home>
                        ${project.build.directory}/tomcat6x/container
                    </home>
                    <properties>
                        <cargo.logging>high</cargo.logging>
                        <cargo.servlet.port>8081</cargo.servlet.port>
                    </properties>
                    <files>
                        <copy>
                          <file>${project.basedir}/src/main/resources/datasource.properties</file>
                          <todir>webapps</todir>
                          <configfile>true</configfile>
                          <overwrite>true</overwrite>
                        </copy>
                    </files>
                    <properties>
                       <customMessage>${catalina.home}</customMessage>
                    </properties>
                </configuration>
            </configuration>
            <executions>
                <execution>
                    <id>start-container</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>configure</goal>
                        <goal>start</goal>
                        <goal>deploy</goal>
                    </goals>
                    <configuration>
                        <deployer>
                            <deployables>
                                <deployable>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <type>war</type>
                                    <pingURL>**the url**</pingURL>
                                    <pingTimeout>180000</pingTimeout>
                                    <properties>
                                        <context>**war-name**</context>
                                    </properties>
                                </deployable>
                            </deployables>
                        </deployer>
                    </configuration>
                </execution>

                <execution>
                    <id>stop-container</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>

但是随着战争开始变得越来越大,ping超时开始增加,我不想使用ping超时,但我现在被迫这样做,因为部署需要一些时间,并且selenium不会等待,如果没有提到 pingtimeout。

这个问题有什么解决办法吗?

i use maven cargo and selenium for automation. here is the code:

<plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.0.5</version>
            <configuration>
                <wait>false</wait>
                <container>
                    <containerId>tomcat6x</containerId>
                    <zipUrlInstaller>
                        <url>
                            http://mirrors.enquira.co.uk/apache/tomcat/tomcat-6/v6.0.30/bin/apache-tomcat-6.0.30.zip
                        </url>
                        <installDir>${installDir}</installDir>
                    </zipUrlInstaller>
                    <output>
                        ${project.build.directory}/tomcat6x.log
                    </output>
                    <log>${project.build.directory}/cargo.log</log>
                </container>
                <configuration>
                    <home>
                        ${project.build.directory}/tomcat6x/container
                    </home>
                    <properties>
                        <cargo.logging>high</cargo.logging>
                        <cargo.servlet.port>8081</cargo.servlet.port>
                    </properties>
                    <files>
                        <copy>
                          <file>${project.basedir}/src/main/resources/datasource.properties</file>
                          <todir>webapps</todir>
                          <configfile>true</configfile>
                          <overwrite>true</overwrite>
                        </copy>
                    </files>
                    <properties>
                       <customMessage>${catalina.home}</customMessage>
                    </properties>
                </configuration>
            </configuration>
            <executions>
                <execution>
                    <id>start-container</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>configure</goal>
                        <goal>start</goal>
                        <goal>deploy</goal>
                    </goals>
                    <configuration>
                        <deployer>
                            <deployables>
                                <deployable>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <type>war</type>
                                    <pingURL>**the url**</pingURL>
                                    <pingTimeout>180000</pingTimeout>
                                    <properties>
                                        <context>**war-name**</context>
                                    </properties>
                                </deployable>
                            </deployables>
                        </deployer>
                    </configuration>
                </execution>

                <execution>
                    <id>stop-container</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>

but as the war started getting bigger the pingtimeout started to increase, i dont want to use ping timeout, but i am being forced to at the moment, as deployment takes a bit of time and selenium does not wait if the pingtimeout is not mentioned.

is there any solution to this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多彩岁月 2024-10-22 20:57:38

使用 Jetty 怎么样? maven-jetty-plugin 将等待您的 web 应用程序加载。或者,您可以使用 tomcat-maven-plugin 及其部署目标通过 Tomcat 管理器将 Web 应用程序部署到正在运行的 Tomcat 实例。该插件还将等待执行(并因此启动 Selenium 测试),直到部署战争。

这是我的配置。它将启动 Jetty、部署应用程序、启动 Selenium、启动 Selenium 测试,最后退出所有服务器:

<plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <configuration>
          <contextPath>/</contextPath>
          <scanIntervalSeconds>0</scanIntervalSeconds>
        </configuration>
        <executions>
          <execution>
            <id>start</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <daemon>true</daemon>
            </configuration>
          </execution>
          <execution>
            <id>stop</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>selenium-maven-plugin</artifactId>
        <configuration>
          <background>true</background>
        </configuration>
        <executions>
          <execution>
            <id>start-selenium</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>start-server</goal>
            </goals>
          </execution>
          <execution>
            <id>stop-selenium</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>
        <executions>
          <execution>
            <id>selenium-tests</id>
            <phase>integration-test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <skip>false</skip>
              <excludes>
                <exclude>none</exclude>
              </excludes>
              <includes>
                <include>**/*SeleniumTest.java</include>
              </includes>
            </configuration>
          </execution>
        </executions>
      </plugin>

What about using Jetty? The maven-jetty-plugin will wait until your webapp is loaded. Alternatively, you can use the tomcat-maven-plugin and its deploy goal to deploy your webapp to a running Tomcat instance through the Tomcat Manager. This plugin will also wait with the execution (and therefore the launch of your Selenium tests) until the war is deployed.

This is my configuration. It will launch Jetty, deploy the application, launch Selenium, launch Selenium tests and finally quits all the servers:

<plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <configuration>
          <contextPath>/</contextPath>
          <scanIntervalSeconds>0</scanIntervalSeconds>
        </configuration>
        <executions>
          <execution>
            <id>start</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <daemon>true</daemon>
            </configuration>
          </execution>
          <execution>
            <id>stop</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>selenium-maven-plugin</artifactId>
        <configuration>
          <background>true</background>
        </configuration>
        <executions>
          <execution>
            <id>start-selenium</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>start-server</goal>
            </goals>
          </execution>
          <execution>
            <id>stop-selenium</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>
        <executions>
          <execution>
            <id>selenium-tests</id>
            <phase>integration-test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <skip>false</skip>
              <excludes>
                <exclude>none</exclude>
              </excludes>
              <includes>
                <include>**/*SeleniumTest.java</include>
              </includes>
            </configuration>
          </execution>
        </executions>
      </plugin>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文