2014-07-09 49 views
2

我想在Maven中運行集成測試時運行Flyway插件。對於集成測試,我使用故障安全插件。用Maven進行集成測試的Flyway插件

首先可以定義兩次Flyway插件嗎?一個用於一般用法(例如從命令行)和一個用於集成測試?如何在Flyway插件中爲集成測試定義單獨的配置?

回答

2

您可以通過插件的不同執行來實現此目的。每個執行都可以有自己的配置。

0

您可以無故障的pre-integration-test階段有不同的配置添加一個執行,看到Maven Failsafe Plugin

Maven的生命週期已運行集成測試四個階段:

  • 預集成,測試建立集成測試環境。
  • 運行集成測試的集成測試。
  • 後整合測試用於拆除集成測試環境。
  • 驗證以檢查集成測試的結果。

Guide to Configuring Plug-ins

使用<處決>標籤

您也可以使用標籤配置的魔力。這是最常用於旨在參與構建生命週期某些階段的mojos。

例如:

<plugin> 
    <groupId>org.flywaydb</groupId> 
    <artifactId>flyway-maven-plugin</artifactId> 
    <version>4.0.3</version> 
    <configuration>   
     <url>jdbc:jtds:sqlserver://myCompany.com/generalDatabase</url> 
     <user>dbUser</user> 
     <password>password</password> 
     <locations> 
      <location>filesystem:src/main/resources/db/migration</location> 
     </locations> 
    </configuration> 
    <dependencies> 
     <dependency> 
      <groupId>net.sourceforge.jtds</groupId> 
      <artifactId>jtds</artifactId> 
      <version>1.2.7</version> 
      <scope>runtime</scope> 
     </dependency> 
    </dependencies> 
    <executions> 
     <execution> 
      <id>integration-test-database-setup</id> 
      <phase>pre-integration-test</phase> 
      <goals> 
       <goal>clean</goal> 
       <goal>migrate</goal> 
      </goals> 
      <configuration>   
       <url>jdbc:jtds:sqlserver://myCompany.com/testDatabase</url> 
       <user>dbUser</user> 
       <password>password</password> 
       <locations> 
        <location>filesystem:src/test/resources/db/migration</location> 
       </locations> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
相關問題