2013-11-10 2 views
1

Теперь я начинаю отдельно встроенный кот с помощью Maven:Автоматический запуск/остановка веб-сервер для веб-интерфейсе тестирует

mvn tomcat7:run 

А затем запустить mvn test цели. Мой вопрос в том, могу ли я настроить maven, чтобы сделать это автоматически? tomcat должен быть запущен до запуска всех тестов, а затем остановлен.

Следующая конфигурация Maven для TOMCAT плагин используется:

 <plugins> 
     <plugin> 
      <groupId>org.apache.tomcat.maven</groupId> 
      <artifactId>tomcat7-maven-plugin</artifactId> 
      <version>2.1</version> 
      <configuration> 
       <path>/SpringMvcExample</path> 
       <url>http://localhost:8080/manager/text</url> 
       <server>tomcat7</server> 
      </configuration> 
     </plugin> 
    </plugins> 

Я пытался обновить конфигурацию плагина для:

<plugin> 
     <groupId>org.apache.tomcat.maven</groupId> 
     <artifactId>tomcat7-maven-plugin</artifactId> 
     <version>2.1</version> 
     <configuration> 
      <path>/SpringMvcExample</path> 
      <url>http://localhost:8080/manager/text</url> 
      <server>tomcat7</server> 
     </configuration> 
     <executions> 
      <execution> 
       <id>start-tomcat</id> 
       <phase>pre-integration-test</phase> 
       <goals> 
        <goal>run</goal> 
       </goals> 
      </execution> 
      <execution> 
       <id>stop-tomcat</id> 
       <phase>post-integration-test</phase> 
       <goals> 
        <goal>shutdown</goal> 
       </goals> 
      </execution> 
     </executions> 
    </plugin> 

Но это не помогло

ответ

2
 attach tomcat:run to pre-integration-test 
     attach tomcat:shutdown to post-integration-test 
Below is the code snippet. 
    <plugin> 
     <groupId>org.apache.tomcat.maven</groupId> 
     <artifactId>tomcat7-maven-plugin</artifactId> 
     <version>2.1</version> 
     <executions> 
      <execution> 
      <id>tomcat-run</id> 
      <goals> 
       <goal>run-war-only</goal> 
      </goals> 
      <phase>pre-integration-test</phase> 
       <configuration> 

        <fork>true</fork> 
       </configuration> 

      </execution> 
      <execution> 
      <id>tomcat-shutdown</id> 
      <goals> 
       <goal>shutdown</goal> 
      </goals> 
      <phase>post-integration-test</phase> 
      </execution> 
     </executions> 
     </plugin> 
+0

укажите, где поставить эти заявления? – Alexandr

+0

обновил мой пост – Sanj

+0

Несколько вопросов. Какую версию maven вы используете? в конфигурации - url и server являются красными в моем редакторе, и, похоже, элемент здесь не разрешен. а второй: как указать, что тест является интеграцией? Имя используемого класса: SimpleViewControllerSeleniumTest – Alexandr

Смежные вопросы