2017-08-30 20 views
1

我正在使用集成測試的故障安全插件,該工具在測試過程中運行良好失敗。執行post-integration-test階段,該階段調用spring-boot:stop。使用相同的模式,我想用Gatling進行性能測試。看起來好像gatling-maven-plugin沒有這種相同的功能,並且在integration-test階段期間的失敗並不能保證post-integration-test被調用。因此,彈簧引導應用程序仍在運行,後續運行將無法啓動。如果Gatling在Maven構建過程中斷言失敗,它將無法進入「後整合測試」階段,這將導致彈簧啓動運行

我已經搜索了幾個小時尋找解決方案的互聯網,但他們都只採取了一半。他們展示瞭如何執行gatling測試,但並未顯示如何在故障中恢復。

gatling插件可以實現這種功能嗎?如果不是,那麼在Maven構建失敗後,如何直接調用post-integration-test階段?

回答

0

足夠的解決方法是將spring-boot-maven-plugin配置爲不分叉。我的應用程序在構建失敗(由於gatling斷言失敗)和構建成功期間按預期停止。

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-maven-plugin</artifactId> 
      <version>${spring.boot.version}</version> 
      <executions> 
       <execution> 
       <goals> 
        <goal>repackage</goal> 
       </goals> 
       </execution> 
       <execution> 
       <phase>pre-integration-test</phase> 
       <goals> 
        <goal>start</goal> 
       </goals> 
       </execution> 
       <execution> 
       <phase>post-integration-test</phase> 
       <goals> 
        <goal>stop</goal> 
       </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

<profile> 
    <id>performance</id> 
    <properties> 
     <skip.integration.tests>true</skip.integration.tests> 
     <skipTests>true</skipTests> 
    </properties> 
    <build> 
     <plugins> 
     <plugin> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-maven-plugin</artifactId> 
      <configuration> 
      <fork>false</fork> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>io.gatling</groupId> 
      <artifactId>gatling-maven-plugin</artifactId> 
      <version>${gatling-plugin.version}</version> 
      <executions> 
      <execution> 
       <goals> 
       <goal>execute</goal> 
       </goals> 
      </execution> 
      </executions> 
     </plugin> 
     </plugins> 
    </build> 
</profile> 
相關問題