2017-08-30 44 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> 
相关问题