简体   繁体   中英

Running jetty web server before selenide tests

I have multi module maven project. One parent and two submodules. In first module I have integration tests, specifically selenide tests, which are testing web application. Web application is in the second module. I want to deploy application via jetty server and then run selenide tests on it in one maven command. 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.

 <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.

<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.

Have a look at this:

How does Junit @Rule work?

JUnit Rules Wiki

Here is described Rule to start a Jetty Server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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