简体   繁体   English

在硒测试之前运行Jetty Web服务器

[英]Running jetty web server before selenide tests

I have multi module maven project. 我有多模块Maven项目。 One parent and two submodules. 一个父级和两个子模块。 In first module I have integration tests, specifically selenide tests, which are testing web application. 在第一个模块中,我有集成测试,尤其是硒化测试,它正在测试Web应用程序。 Web application is in the second module. Web应用程序在第二个模块中。 I want to deploy application via jetty server and then run selenide tests on it in one maven command. 我想通过码头服务器部署应用程序,然后在一个maven命令中对其运行硒化测试。 I have tried more solutions and here are few of them. 我尝试了更多的解决方案,但是其中很少。

In the module with web app I set up jetty plugin to run server before tests. 在带有Web应用程序的模块中,我设置了码头插件以在测试之前运行服务器。

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

and failsafe-maven-plugin. 和failsafe-maven-plugin。

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>failsafe-maven-plugin</artifactId>
    <version>2.4.3-alpha-1</version>
    <executions>
      <execution>
        <goals>
          <goal>integration-test</goal>
          <goal>verify</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

But problem is that plugin not find any tests because they are in other module. 但是问题是插件找不到任何测试,因为它们在其他模块中。

Can you tell me how to set up failsafe to find test in first module ? 您能告诉我如何设置故障保护以在第一个模块中找到测试吗? Or other solution for example run it from parent ? 还是其他解决方案,例如从父级运行它?

Well, I'm not an expert, maybe JUnit @Rule is that can help you to solve your task: to initialise, deploy and test your web app. 好吧,我不是专家,也许JUnit @Rule可以帮助您解决任务:初始化,部署和测试Web应用程序。

Have a look at this: 看看这个:

How does Junit @Rule work? Junit @Rule如何工作?

JUnit Rules Wiki JUnit规则Wiki

Here is described Rule to start a Jetty Server 这里描述了启动Jetty服务器的规则

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

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